JSON-RPC support for serving fake coins#25916
Open
mystenmark wants to merge 16 commits intointegrate-coin-smashingfrom
Open
JSON-RPC support for serving fake coins#25916mystenmark wants to merge 16 commits intointegrate-coin-smashingfrom
mystenmark wants to merge 16 commits intointegrate-coin-smashingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
When clients don't understand address balances, the JSON-RPC server can return "fake" coin objects representing address balances. The fake coin is always returned at position 1 (second position) in the getCoins results, after the first real coin. Changes: - Add encode_object_ref() helper to coin_reservation module - Add get_address_balance_coin_info() to AuthorityState - Update get_owned_coins() to include fake coin at position 1 - Handle pagination correctly - fake coin only returned once - Add RPC integration tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5d32db1 to
3594b9c
Compare
- Extract to_sui_coin helper function (eliminates 7 repetitions) - Only fetch first_real_coin when actually needed - Use iterator chaining with .extend() and .take() - Reduce deeply nested conditionals Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use grpc_client instead of deprecated rpc_client field. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit aecc454.
a30cd39 to
5114936
Compare
5114936 to
e58c5ba
Compare
e58c5ba to
0af0fa5
Compare
Only need limit+1 real coins when skip_first is true (cursor at fake coin), not limit*2 in all cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
485ad32 to
cb71388
Compare
- Remove extra DB query to check cursor_at_first_real - Replace multiple state variables with two HashMaps (fake_emitted, seen_first_real) - Simplify cursor state detection: non-zero cursor not at fake = past fake slot - Cleaner iteration loop with less branching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The getAllCoins test requires real coins to exist for each coin type to verify fake coin ordering. Modify publish_and_mint_trusted_coin to mint two coins: one for address balance and one to keep as a real coin. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per PR review feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bug fix: When getAllCoins was called with multiple coin types where some types had only address balance (no real coins), the fake coins for those types were not being emitted. This is because the fallback logic only triggered when ALL types had no real coins. Also refactored the RPC tests to use a data-driven approach: - Added CoinTypeConfig struct to specify test scenarios - Added helper methods: transfer_sui_coin, fund_address_balance_for_recipient, publish_trusted_coin_and_setup - Created parameterized scenario tests that verify both getCoins and getAllCoins return correct real/fake coin counts - Added test_scenario_two_types_custom_address_balance_only which specifically tests the bug fix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactored TestEnv to use composable building blocks: - publish_trusted_coin: just publishes, returns (package_id, coin_type, treasury_cap) - mint_trusted_coin: mints one coin, returns (coin_ref, new_treasury_cap) - transfer_coin: transfers any coin to recipient - transfer_sui: transfers SUI from gas to recipient - transfer_sui_to_address_balance: transfers SUI to recipient's address balance publish_trusted_coin_and_setup now composes these primitives. Legacy publish_and_mint_trusted_coin preserved as a wrapper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
suix_getCoinsandsui_getObjectgetCoinsresultsStack: Depends on #25818
Changes
encode_object_ref()helper tocoin_reservationmoduleget_address_balance_coin_info()toAuthorityStateget_object_read()to return fake coins for masked object IDsget_owned_coins()to include fake coin at position 1Test plan
test_rpc_get_object_returns_fake_coin: verifiessui_getObjecttest_rpc_get_coins_includes_fake_coin_at_position_1: verifies fake coin at position 1test_rpc_get_coins_pagination_handles_fake_coin: verifies paginationtest_rpc_get_balance_includes_address_balance: verifiessuix_getBalance🤖 Generated with Claude Code