Skip to content

Add stacking_info field to ContractInfo #1365

@manishdait

Description

@manishdait

The protobuf ContractGetInfoResponse.ContractInfo message includes a staking_info field that provides staking-related metadata for contracts. This field is already supported and exposed in the other SDK, but it is currently missing from the Python SDK ContractInfo class.

Proposed Solution

  • Add a new optional field to the Python ContractInfo class:
    staking_info: Optional[StakingInfo] = None
  • Update from_proto() to correctly deserialize staking data:
    # eg
     @classmethod
      def _from_proto(cls, proto: ContractGetInfoResponse.ContractInfo) -> "ContractInfo":
          ...  
          return cls(
              ...,
              staking_info=(
                 StakingInfo.from_proto(proto.stakingInfo)
                 if proto.HasField("stakingInfo")
                 else None
              )
           )
  • Update to_proto to serialize staking data back to protobuf:
    def _to_proto(self) -> ContractGetInfoResponse.ContractInfo:
          ....
          return ContractGetInfoResponse.ContractInfo(
              ...,
              staking_info=(
                self.staking_info.to_proto()
                if self.staking_info is not None
                else None
                )
            )
  • Ensure unit test for fromBytes / toBytes round-tripping includes staking information once added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Blockchain / DLTIssues engineering distributed ledger functionalityenhancementNew feature or requestintermediaterequires some knowledge of the codebase with some defined steps to implement or examplespythonUses Python programming language

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions