Skip to content

commit for claimable balance rework to use RPC in the docs - #1784

Merged
karthikiyer56 merged 4 commits into
mainfrom
karthik/cb-rework
Sep 17, 2025
Merged

karthikiyer56 merged 4 commits into
mainfrom
karthik/cb-rework

Conversation

@karthikiyer56

@karthikiyer56 karthikiyer56 commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

This PR fixes #1744

@karthikiyer56
karthikiyer56 marked this pull request as ready for review September 16, 2025 20:58
@karthikiyer56
karthikiyer56 requested a review from a team September 16, 2025 20:58
@karthikiyer56 karthikiyer56 changed the title Initial commit for claimable balance id commit for claimable balance rework to use RPC in the docs Sep 16, 2025
txResponse.envelope_xdr,
Networks.TESTNET,
);
console.log("Balance ID (1):", builder.build().getClaimableBalanceId(0));

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.

I think it's important to highlight that the claimable balance IDs are predictable, i.e. you don't need to submit the operation to know what it's going to be. Maybe it doesn't belong in this part of the flow any more but I don't think it should be dropped entirely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm.
thats a fair point.
As you can imagine, this snippet doesnt lend itself to the reworked examples anymore, since I am not using the txResponse anymore, and the examples are complete in and of themselves.

I have made a note of this recommendation and will add it as a separate issue to add "somewhere" - maybe in claimable balance operations page?

rpcClient := client.NewClient("https://soroban-testnet.stellar.org", nil)
defer rpcClient.Close()

if CLAIMANT_SECRET == "PASTE_CLAIMANT_SECRET_HERE" {

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.

You prefill above it so this check seems unnecessary

@Shaptic Shaptic 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.

LGTM! Just make sure your <Details> renders right 👍

Comment on lines +69 to +71
<Details summary="Click here to see helper functions">

<CodeExample>

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.

I've found that this will only render correctly without a line break between Details and CodeExample, for some reason. Check my work once the preview renders of course but I've noticed that the summary won't show without that break removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep!.
Painfully aware of this from past experiences of using the code example pragma.

The preview here renders fine and I am just going by that as proof of correctness

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wait a minute!.
I just reread this.
I think a line break is needed between details and code example

@karthikiyer56
karthikiyer56 merged commit f0655fc into main Sep 17, 2025
@karthikiyer56
karthikiyer56 deleted the karthik/cb-rework branch September 17, 2025 18:15
ElliotFriend pushed a commit that referenced this pull request Sep 8, 2026
* Update Verify Trustlines guide to use RPC instead of Horizon

Removes the Horizon section and rebuilds the RPC section around the
modern JS SDK helpers.

- Delete "Checking a Trustline through the Horizon API" entirely, matching
  the sibling migrations (#1769, #1779, #1784, #1786, #1793).
- Split the RPC section in two: `getAssetBalance` for existence and
  authorization, `getLedgerEntries` for the trustline limit (which
  `getAssetBalance` does not surface).
- Use the public `getLedgerEntries` instead of the private
  `_getLedgerEntries`, which also drops the manual
  `xdr.LedgerEntryData.fromXDR` step since `entries[].val` is already
  decoded.
- Fix a correctness bug: trustline flags are a bitfield, so
  `flags() !== 1` wrongly reported an authorized, clawback-enabled
  trustline (flags = 5) as unauthorized. Now checks `flags() & 1`.
- Replace the hardcoded receiver, which 404s on Testnet after a reset,
  with a placeholder plus guidance on creating one.
- SAC section: `authorized` does not return false for a missing
  trustline — the simulation fails with Error(Contract, #13) — so
  document which branch handles which case. Also point the bindings
  command at ./sac so the generated package name matches the
  `import { Client } from "sac"` below it, and drop a leftover
  commented-out transfer block.
- Link to the official Migrate from Horizon to RPC page, which documents
  that RPC does not return trustlines alongside accounts.

All snippets were run against Testnet with @stellar/stellar-sdk 16.2.0,
covering the missing-trustline, authorized, and insufficient-limit paths.

Fixes #1743

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Address review: fix int64 precision and error conflation

- Keep trustline limit arithmetic in BigInt stroops. Converting int64
  amounts through Number loses precision above 2^53-1, and trustline
  limits routinely sit at the int64 maximum (922,337,203,685.4775807).
  The old Number path falsely rejected valid payments: with a limit at
  the maximum and 1000 stroops of headroom, sending 0.0001 was reported
  as exceeding the limit. Adds a `toStroops` helper so the amount to send
  is converted without going through a float, and links the Amount
  precision reference.

- Drop the same Number conversion from the getAssetBalance snippet and
  report `amount` as the stroops string the SDK returns.

- Stop reporting every getAssetBalance failure as "trustline not found".
  The SDK's getTrustline swallows the underlying error and always throws
  the same "not found" message, so an unreachable RPC endpoint is
  indistinguishable from a genuinely missing trustline. The example now
  rethrows the original error and says "could not confirm", and a warning
  documents the caveat and points at getLedgerEntries, which returns an
  empty entries array for a missing trustline and only rejects on a
  transport error.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Wlad Mendes <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

Update Claimable Balances Guide to use RPC instead of Horizon

3 participants