Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@basfroman
Copy link
Collaborator

@basfroman basfroman commented Nov 7, 2025

Context

This PR introduces a new pallet-based architecture for creating GenericCall objects without immediate submission. This is an intermediate step toward full Proxy pallet support, which requires the ability to compose nested calls where one GenericCall is passed as a parameter to another.

Changes

  • New CallBuilder base class: Provides a unified interface for creating GenericCall instances from any Subtensor pallet.
  • Pallet implementations: Added factory classes for Balances, Crowdloan, Sudo, SubtensorModule, Swap, and Commitments.
  • Unified async/sync support: All pallets work seamlessly with both Subtensor and AsyncSubtensor instances.
  • Refactored extrinsics: Updated transfer and start_call extrinsics to use the new pallet architecture.

Benefits

  • No code duplication: GenericCall objects can be created once and reused for fee estimation, submission, or nesting in other calls.
  • Type safety: Methods return Union[GenericCall, Awaitable[GenericCall]] based on the subtensor type.
  • Backward compatible: Existing extrinsic functions continue to work unchanged.
  • Extensible: New pallets can be easily added by extending CallBuilder.
  • The entire SDK API is backward compatible.
  • All builder methods are implemented consistently with Subtensor functions.

Example Usage

Create a sync call without submitting

subtensor = bt.Subtensor("local")
call = SubtensorModule(subtensor).start_call(netuid=14)

Create a async call without submitting

async_subtensor = bt.AsyncSubtensor("local")
call = await SubtensorModule(async_subtensor).start_call(netuid=14)

Use for fee estimation

fee = subtensor.get_extrinsic_fee(call, wallet.coldkeypub)

Submit the call

response = subtensor.sign_and_send_extrinsic(call=call, wallet=wallet)

Nest calls (preparation for Proxy support)

inner_call = SubtensorModule(subtensor).start_call(netuid=14)
sudo_call = Sudo(subtensor).sudo(call=inner_call)
response = subtensor.sign_and_send_extrinsic(call=sudo_call, wallet=wallet)

Dynamic call creation within defined pallet class

call = SubtensorModule(subtensor, dynamic_function=True).burned_register(
    netuid=14, 
    hotkey=alice_wallet.hotkey.ss58_address,
)
response = subtensor.sign_and_send_extrinsic(call=call, wallet=wallet)

Dynamic call creation without defined pallet class

call = CallBuilder(subtensor, dynamic_function=True).create_composed_call(
    call_module="SubtensorModule",
    call_function="burned_register",
    netuid=14, 
    hotkey=alice_wallet.hotkey.ss58_address,
)
response = subtensor.sign_and_send_extrinsic(call=call, wallet=wallet)

Testing

@basfroman basfroman self-assigned this Nov 7, 2025
@basfroman basfroman added the feature new feature added label Nov 7, 2025
This was referenced Nov 7, 2025
"""

subtensor: Union["Subtensor", "AsyncSubtensor"]
dynamic_function: bool = False
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is great, but how does this actually get used? Like I see it in the tests, but how does a user go about using this, or rather why is it not just enabled by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You know, I was thinking of introducing more strictness. But I like your approach too. Although I'll keep the logic of using CallBuilder.dynamic_function . There will always be users who want to control the behavior themselves.

@basfroman basfroman merged commit d0d9508 into SDKv10 Nov 10, 2025
498 checks passed
@basfroman basfroman deleted the feat/roman/create-subtensor-callls-logic branch November 10, 2025 23:18
@basfroman basfroman mentioned this pull request Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature new feature added

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants