Skip to content

Stop adding the restore resource fee twice in the JS and Python examples - #3160

Open
theluckystrike wants to merge 2 commits into
stellar:mainfrom
theluckystrike:fix-restore-fee-double-count
Open

theluckystrike wants to merge 2 commits into
stellar:mainfrom
theluckystrike:fix-restore-fee-double-count

Conversation

@theluckystrike

Copy link
Copy Markdown
Contributor

Closes #3134

TransactionBuilder.build() already adds the Soroban data's resource fee to the fee (js-stellar-sdk src/base/transaction_builder.ts:1042, py-stellar-base stellar_sdk/transaction_builder.py:152). The restore examples also added minResourceFee by hand, so the fee bid counted it twice.

Changes, same in both pages:

  • Restore tx: the fee is now the inclusion fee only. The comment says build() adds the resource fee, like the Java tabs from Add Java examples to the learn pages #3133.
  • Retry tx: dropped the fee option from cloneFrom. cloneFrom already removes the old resource fee before it derives the base fee, and build() adds the new one from sim.transactionData.
  • Python tab in restore-data: same fix as the JS restore tx. The Python tab in state-archival was already right.

Docs only, 2 files. I checked each line against the SDK source on main. I did not run the snippets against testnet.

@mintlify

mintlify Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit d126d1d.

Approve preview

@stellar-triage-bot

Copy link
Copy Markdown
Contributor

🤖 Automated message from the Stellar Triage Bot.

Hi @theluckystrike, thanks for the PR. I saw it, but I review only when someone calls me in. A maintainer will look at it.

How to reach me:

  • Anyone with write permission can call me in with a /triage comment or the bot:take label.
  • You, as the PR author, can send me away with /triage stop. People with write permission can also use the bot:hands-off label.
  • A review request to a maintainer does not call me in. It asks for their judgment.

@kaankacar

Copy link
Copy Markdown
Contributor

/triage

@stellar-triage-bot stellar-triage-bot Bot added the bot:ready-to-merge Bot verified and approved; waiting for a maintainer to merge label Nov 16, 2026
@stellar-triage-bot

Copy link
Copy Markdown
Contributor

🤖 Automated message from the Stellar Triage Bot.

Reviewing because @kaankacar asked with /triage.

Verified: build() already adds the resource fee, so the fix is right in all five places. I pushed one fix to the retry lines this PR edits. The JS retry now uses assembleTransaction(tx, sim), because cloneFrom dropped the simulated auth. The other tabs already attach it. Ready to merge.

Not run: the JS and Python restore snippets on both pages. No live preview was available. External-origin change, so a maintainer merges this.

What I checked
  • Checked against @stellar/stellar-sdk 17.4.0, stellar-sdk (PyPI) 17.0.1, and stellar-rpc v30.0.1. The issue cited the same SDK versions. The pages pin none.
  • JS build() adds sorobanData.resourceFee: js-stellar-sdk@v17.4.0 src/base/transaction_builder.ts:1135-1140. The PR body cites :1042 on main.
  • JS cloneFrom subtracts the resource fee before it derives the base fee, and opts.fee replaces that value: transaction_builder.ts:360-388.
  • JS assembleTransaction keeps the same fee result and adds the simulated auth: js-stellar-sdk@v17.4.0 src/rpc/transaction.ts:69-127.
  • Python build() adds soroban_data.resource_fee: py-stellar-base@17.0.1 stellar_sdk/transaction_builder.py:149-151.
  • minResourceFee equals the resourceFee inside the returned transaction data, for both the invocation and the restore preamble: stellar-rpc@v30.0.1 cmd/stellar-rpc/lib/preflight/src/shared.rs:103-106,138,143.
  • The state-archival Python tab sets the resource fee to min_resource_fee (the same value) and adds nothing by hand, so it pays once.
  • Sweep: searched docs/, snippets/, openapi/, openrpc/, and .mintlify/skills/ for minResourceFee, min_resource_fee, MinResourceFee, restorePreamble, restore_preamble, RestorePreamble, set_resource_fee, and parseInt(tx.fee). No other copy of the double count. dapps/state-archival.mdx bids the inclusion fee only and lets prepareTransaction add the resource fee. The PHP snippet in working-with-contract-specs.mdx adds the fee once, because PHP's addResourceFee is the only addition there.
  • Necessity: the old code added the resource fee to the inclusion-fee bid as well, so the bid could pass the reader's MAX_FEE cap.
  • Checks at d126d1d4: checks, complete, and Socket pass. The fork preview was not built.
  • Not verified: no snippet was run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:ready-to-merge Bot verified and approved; waiting for a maintainer to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JavaScript and Python restore examples pay the restore resource fee twice

2 participants