Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/util/transactions/hooks/delegation-7702-publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,34 @@ describe('Delegation 7702 Publish Hook', () => {
});
});

it('throws when atomic batch is not supported for a gas-sponsored transaction', async () => {
await expect(
hookClass.getHook()(
{
...TRANSACTION_META_MOCK,
isGasFeeSponsored: true,
},
SIGNED_TX_MOCK,
),
).rejects.toThrow(
'Gas Station 7702: Chain must support EIP-7702 for sponsored or gas included transaction',
);
});

it('throws when atomic batch is not supported for a gas-included transaction', async () => {
await expect(
hookClass.getHook()(
{
...TRANSACTION_META_MOCK,
isGasFeeIncluded: true,
},
SIGNED_TX_MOCK,
),
).rejects.toThrow(
'Gas Station 7702: Chain must support EIP-7702 for sponsored or gas included transaction',
);
});

it('no selected gas fee token', async () => {
isAtomicBatchSupportedMock.mockResolvedValueOnce([
{
Expand Down
16 changes: 10 additions & 6 deletions app/util/transactions/hooks/delegation-7702-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ export class Delegation7702PublishHook {
transactionMeta;

const { from } = txParams;
const isGaslessBridge = Boolean(transactionMeta.isGasFeeIncluded);
const isSponsored = Boolean(transactionMeta.isGasFeeSponsored);

const atomicBatchSupport = await this.#isAtomicBatchSupported({
address: from as Hex,
Expand All @@ -137,16 +139,19 @@ export class Delegation7702PublishHook {

if (!isChainSupported) {
log('Skipping as EIP-7702 is not supported', { from, chainId });

if (isGaslessBridge || isSponsored) {
throw new Error(
'Chain must support EIP-7702 for sponsored or gas included transaction',
);
}

return EMPTY_RESULT;
}

const { delegationAddress, upgradeContractAddress } =
atomicBatchChainSupport;

const isGaslessBridge = transactionMeta.isGasFeeIncluded;

const isSponsored = Boolean(transactionMeta.isGasFeeSponsored);

if (
(!selectedGasFeeToken || !gasFeeTokens?.length) &&
!isGaslessBridge &&
Expand All @@ -173,8 +178,7 @@ export class Delegation7702PublishHook {
parseInt(isE2ETest(chainId) ? SEPOLIA_CHAIN_ID : chainId, 16),
);
const delegationManagerAddress = delegationEnvironment.DelegationManager;
const includeTransfer =
!isGaslessBridge && !transactionMeta.isGasFeeSponsored;
const includeTransfer = !isGaslessBridge && !isSponsored;

if (includeTransfer && (!gasFeeToken || gasFeeToken === undefined)) {
throw new Error('Gas fee token not found');
Expand Down
Loading