Skip to content

chore: remove fee compute for swap transaction and muliplier base inclusion fee for simulation#139

Merged
stanleyyconsensys merged 4 commits into
mainfrom
chore/remove-fee-compute-swap
Jun 29, 2026
Merged

chore: remove fee compute for swap transaction and muliplier base inclusion fee for simulation#139
stanleyyconsensys merged 4 commits into
mainfrom
chore/remove-fee-compute-swap

Conversation

@stanleyyconsensys

Copy link
Copy Markdown
Collaborator

Explanation

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates swap-transaction validation so that fee computation is no longer applied when decoding/validating a swap envelope from XDR, and adjusts the related unit test expectations.

Changes:

  • Update TransactionService.createValidatedSwapTransaction to stop using the computingFee return value and return the original decoded transaction.
  • Update TransactionService swap-validation test expectations around Soroban invoke swap simulation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/snap/src/services/transaction/TransactionService.ts Stops propagating the computingFee result through swap validation/return path.
packages/snap/src/services/transaction/TransactionService.test.ts Updates Soroban swap validation test assertions to match the new return behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +399 to +401
// Bridge API swap transaction already include the fee — we trust it and do not recalculate.
// For Soroban invokes, computingFee simulates the transaction to validate it.
await this.computingFee(transaction);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is expected, as we only using compute fee method to simulate if the txn is get though or not

Comment thread packages/snap/src/services/transaction/TransactionService.test.ts Outdated
Julink-eth
Julink-eth previously approved these changes Jun 26, 2026
@stanleyyconsensys stanleyyconsensys changed the title chore: remove fee compute for swap transaction chore: remove fee compute for swap transaction and muliplier base inclusion fee for simulation Jun 27, 2026
);
}

// Get the min resource fee from the simulation response.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

further to Stellar Team suggest, we should no need to change the resource fee

instead we should change the base fee (inclusion fee)

timeout: this.#getTimeout(),
scope,
// Base fee is a placeholder until RPC simulation.
fee: BASE_FEE.toString(),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont use fix fee here

'Invalid fee amount, falling back to configured inclusion fee',
);
fee = BASE_FEE;
fee = baseInclusionFee();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for fallback case, we should also do multiplier with the base fee

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Comment thread packages/snap/src/services/transaction/TransactionService.ts Outdated
Comment thread packages/snap/src/services/transaction/TransactionService.ts Outdated
Comment on lines 121 to 129
/**
* Fetches the current base fee per operation from the Stellar network.
* Fetches the current Stellar network base fee and applies
* {@link AppConfig.transaction.baseFeeMultiplier} to produce the per-operation inclusion fee.
*
* @param scope - The CAIP-2 chain ID.
* @returns A Promise that resolves to the base fee as BigNumber.
* @returns A Promise that resolves to the inclusion fee in stroops.
* @throws {NetworkServiceException} If the fee cannot be fetched.
*/
async getBaseFee(scope: KnownCaip2ChainId): Promise<BigNumber> {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we keep getBaseFee for now, otherwise, it will be a lot of changes

Comment on lines 1204 to 1208
isSimErrorSpy.mockRestore();
});

it('applies simulationFeeMultiplier to minResourceFee before assembling', async () => {
const { simulateTransactionSpy } = getRpcServerSpies();
const mockInvoke = createMockInvokeHostFunctionTransaction();
const minResourceFee = '1000';
const transactionData = new SorobanDataBuilder();
const setResourceFeeSpy = jest.spyOn(transactionData, 'setResourceFee');
simulateTransactionSpy.mockResolvedValue({
// eslint-disable-next-line @typescript-eslint/naming-convention
_parsed: true,
id: '1',
latestLedger: 1,
events: [],
minResourceFee,
transactionData,
result: { auth: [] },
} as never);

const result = await networkService.simulateTransaction(
mockInvoke,
scope,
);

expect(result).toBeInstanceOf(Transaction);
expect(setResourceFeeSpy).toHaveBeenCalledWith(
new BigNumber(minResourceFee)
.multipliedBy(AppConfig.transaction.simulationFeeMultiplier)
.toString(),
);
});

it('calls RPC simulateTransaction with the wrapped envelope getRaw()', async () => {
const { simulateTransactionSpy } = getRpcServerSpies();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is no need to add a regression test

@stanleyyconsensys stanleyyconsensys merged commit efdc1df into main Jun 29, 2026
10 checks passed
@stanleyyconsensys stanleyyconsensys deleted the chore/remove-fee-compute-swap branch June 29, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants