diff --git a/packages/common/src/types.ts b/packages/common/src/types.ts index 4be923d6..ae0579f4 100644 --- a/packages/common/src/types.ts +++ b/packages/common/src/types.ts @@ -1,5 +1,6 @@ import type EventEmitter from 'node:events'; import type { + BN, BytesLike, Predicate as FuelPredicate, Provider as FuelProvider, @@ -53,3 +54,15 @@ export type SignedMessageCustomCurve = { curve: string; signature: string; }; + +export interface PaymasterParams { + paymasterAddress: string; + maxFeePerGas?: BN; + deadline?: number; +} + +export interface SendTransactionParams { + skipCustomFee?: boolean; + onBeforeSend?: (txRequest: TransactionRequest) => Promise; + paymaster?: PaymasterParams; +} diff --git a/packages/fuel-wallet/src/FuelWalletConnector.ts b/packages/fuel-wallet/src/FuelWalletConnector.ts index e7157562..ecd3b94f 100644 --- a/packages/fuel-wallet/src/FuelWalletConnector.ts +++ b/packages/fuel-wallet/src/FuelWalletConnector.ts @@ -199,27 +199,13 @@ export class FuelWalletConnector extends FuelConnector { if (!transaction) { throw new Error('Transaction is required'); } + let txRequest = transactionRequestify(transaction); - // Log the incoming transaction details - console.log('FuelWalletConnector - Incoming Transaction:', { - inputs: transaction.inputs?.map((input) => ({ - type: input.type, - owner: 'owner' in input ? input.owner : undefined, - amount: 'amount' in input ? input.amount?.toString() : undefined, - assetId: 'assetId' in input ? input.assetId : undefined, - })), - outputs: transaction.outputs?.map((output) => ({ - type: output.type, - to: 'to' in output ? output.to : undefined, - amount: 'amount' in output ? output.amount?.toString() : undefined, - assetId: 'assetId' in output ? output.assetId : undefined, - })), - witnesses: transaction.witnesses?.length, - params, - }); + if (params?.onBeforeSend) { + txRequest = await params.onBeforeSend(txRequest); + } // Transform transaction object to a transaction request - const txRequest = transactionRequestify(transaction); /** * @todo We should remove this once the chainId standard start to be used and chainId is required @@ -230,15 +216,6 @@ export class FuelWalletConnector extends FuelConnector { url: network.url, }; - // Log the final request being sent - console.log('FuelWalletConnector - Sending Request:', { - address, - provider, - skipCustomFee: params?.skipCustomFee, - maxFee: txRequest.maxFee?.toString(), - tip: txRequest.tip?.toString(), - }); - return this.client.request('sendTransaction', { address, transaction: JSON.stringify(txRequest),