diff --git a/background/networks.ts b/background/networks.ts index 322ab8a09..7b05b33d6 100644 --- a/background/networks.ts +++ b/background/networks.ts @@ -162,6 +162,7 @@ export type LegacyEVMTransactionRequest = Pick< estimatedRollupFee: bigint estimatedRollupGwei: bigint nonce?: number + broadcastOnSign: boolean } /** @@ -219,6 +220,7 @@ export type EIP1559TransactionRequest = Pick< gasLimit: bigint chainID: EIP1559Transaction["network"]["chainID"] nonce?: number + broadcastOnSign: boolean } export type TransactionRequest = diff --git a/background/services/chain/index.ts b/background/services/chain/index.ts index d436699c0..f368b7ca2 100644 --- a/background/services/chain/index.ts +++ b/background/services/chain/index.ts @@ -530,8 +530,17 @@ export default class ChainService extends BaseService { transactionRequest: EnrichedLegacyTransactionRequest gasEstimationError: string | undefined }> { - const { from, to, value, gasLimit, input, gasPrice, nonce, annotation } = - partialRequest + const { + from, + to, + value, + gasLimit, + input, + gasPrice, + nonce, + annotation, + broadcastOnSign, + } = partialRequest // Basic transaction construction based on the provided options, with extra data from the chain service const transactionRequest: EnrichedLegacyTransactionRequest = { from, @@ -553,6 +562,7 @@ export default class ChainService extends BaseService { ? await this.estimateL1RollupGasPrice(network) : 0n, estimatedRollupFee: 0n, + broadcastOnSign, } if (network.chainID === OPTIMISM.chainID) { @@ -628,6 +638,7 @@ export default class ChainService extends BaseService { maxPriorityFeePerGas, nonce, annotation, + broadcastOnSign, } = partialRequest // Basic transaction construction based on the provided options, with extra data from the chain service @@ -644,6 +655,7 @@ export default class ChainService extends BaseService { chainID: network.chainID, nonce, annotation, + broadcastOnSign, } // Always estimate gas to decide whether the transaction will likely fail. diff --git a/background/services/chain/tests/index.unit.test.ts b/background/services/chain/tests/index.unit.test.ts index 9f0196842..1296d3a54 100644 --- a/background/services/chain/tests/index.unit.test.ts +++ b/background/services/chain/tests/index.unit.test.ts @@ -67,6 +67,7 @@ describe("Chain Service", () => { nonce: 1, maxPriorityFeePerGas: 1n, maxFeePerGas: 2n, + broadcastOnSign: true, } const stub = sandbox.stub( @@ -98,6 +99,7 @@ describe("Chain Service", () => { network: OPTIMISM, nonce: 1, gasPrice: 1_000n, + broadcastOnSign: true, } const stub = sandbox.stub( diff --git a/background/services/enrichment/types.ts b/background/services/enrichment/types.ts index 31fd98856..09791703d 100644 --- a/background/services/enrichment/types.ts +++ b/background/services/enrichment/types.ts @@ -99,6 +99,7 @@ export type EnrichedEIP1559TransactionSignatureRequest = from: string annotation?: TransactionAnnotation network: EVMNetwork + broadcastOnSign: boolean } export type EnrichedLegacyTransactionSignatureRequest = @@ -106,6 +107,7 @@ export type EnrichedLegacyTransactionSignatureRequest = from: string annotation?: TransactionAnnotation network: EVMNetwork + broadcastOnSign: boolean } export type EnrichedEIP1559TransactionRequest = EIP1559TransactionRequest & { @@ -121,10 +123,18 @@ export type EnrichedEVMTransactionRequest = | EnrichedLegacyTransactionRequest type PartialEIP1559TransactionRequestWithFrom = - Partial & { from: string; network: EVMNetwork } + Partial & { + from: string + network: EVMNetwork + broadcastOnSign: boolean + } type PartialLegacyEVMTransactionRequestWithFrom = - Partial & { from: string; network: EVMNetwork } + Partial & { + from: string + network: EVMNetwork + broadcastOnSign: boolean + } export type PartialTransactionRequestWithFrom = | PartialEIP1559TransactionRequestWithFrom diff --git a/background/services/internal-ethereum-provider/index.ts b/background/services/internal-ethereum-provider/index.ts index 5af289d20..495a528ef 100644 --- a/background/services/internal-ethereum-provider/index.ts +++ b/background/services/internal-ethereum-provider/index.ts @@ -109,6 +109,7 @@ type Events = ServiceLifecycleEvents & { Partial & { from: string network: EVMNetwork + broadcastOnSign: boolean }, SignedTransaction > @@ -245,6 +246,7 @@ export default class InternalEthereumProviderService extends BaseService ...(params[0] as JsonRpcTransactionRequest), }, origin, + true, ).then(async (signed) => { await this.chainService.broadcastSignedTransaction(signed) return signed.hash @@ -253,6 +255,7 @@ export default class InternalEthereumProviderService extends BaseService return this.signTransaction( params[0] as JsonRpcTransactionRequest, origin, + false, ).then((signedTransaction) => serializeEthersTransaction( ethersTransactionFromSignedTransaction(signedTransaction), @@ -394,6 +397,7 @@ export default class InternalEthereumProviderService extends BaseService private async signTransaction( transactionRequest: JsonRpcTransactionRequest, origin: string, + broadcastOnSign: boolean, ): Promise { const annotation = origin === TAHO_INTERNAL_ORIGIN && @@ -457,6 +461,7 @@ export default class InternalEthereumProviderService extends BaseService from, network: currentNetwork, annotation, + broadcastOnSign, }, resolver: resolve, rejecter: reject, diff --git a/background/tests/factories.ts b/background/tests/factories.ts index 18b7e0c2f..e9736f7f7 100644 --- a/background/tests/factories.ts +++ b/background/tests/factories.ts @@ -245,6 +245,7 @@ export const createTransactionRequest = ( gasLimit: 0n, chainID: "0", network: ETHEREUM, + broadcastOnSign: true, ...overrides, }) @@ -264,6 +265,7 @@ export const createLegacyTransactionRequest = ( to: "0xdef1c0ded9bec7f1a1670819833240f027b25eff", type: 0, value: 10000000000000000n, + broadcastOnSign: true, ...overrides, }) diff --git a/ui/components/DAppConnection/DAppConnectionInfoBar.tsx b/ui/components/DAppConnection/DAppConnectionInfoBar.tsx index 4527c18e4..609dfe068 100644 --- a/ui/components/DAppConnection/DAppConnectionInfoBar.tsx +++ b/ui/components/DAppConnection/DAppConnectionInfoBar.tsx @@ -35,6 +35,7 @@ function DefaultConnectionPopover({ close }: PopoverProps): ReactElement { >
- + {name ?? shortenedAddress} +