polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
239 stars 111 forks source link

Added multiple params as key support for query_map #351

Closed arjanz closed 10 months ago

arjanz commented 10 months ago

Possibility to omit multiple parameters when using query_map, which was bound to only the last parameter.

For example:

result = self.kusama_substrate.query_map(
            module='ConvictionVoting',
            storage_function='VotingFor',
            max_results=10
        )
print([record for record in result])

# [[(<scale_info::0(value=Cwvu9hqzqCMMK8yLVAcSKPjMDs2yQrrfEpAV3ZVJqpQz7RJ)>, <U16(value=0)>), <scale_info::600(value={'Casting': {'votes': [(72, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (86, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (122, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}})], 'delegations': {'votes': 58500000000000000, 'capital': 58500000000000000}, 'prior': (0, 0)}})>], [(<scale_info::0(value=Cwvu9hqzqCMMK8yLVAcSKPjMDs2yQrrfEpAV3ZVJqpQz7RJ)>, <U16(value=14)>), <scale_info::600(value={'Casting': {'votes': [], 'delegations': {'votes': 57000000000000000, 'capital': 57000000000000000}, 'prior': (0, 0)}})>], [(<scale_info::0(value=Cwvu9hqzqCMMK8yLVAcSKPjMDs2yQrrfEpAV3ZVJqpQz7RJ)>, <U16(value=15)>), <scale_info::600(value={'Casting': {'votes': [(39, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}}), (80, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (91, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (96, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}})], 'delegations': {'votes': 57000000000000000, 'capital': 57000000000000000}, 'prior': (0, 0)}})>], [(<scale_info::0(value=Cwvu9hqzqCMMK8yLVAcSKPjMDs2yQrrfEpAV3ZVJqpQz7RJ)>, <U16(value=10)>), <scale_info::600(value={'Casting': {'votes': [(16, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}})], 'delegations': {'votes': 57000000000000000, 'capital': 57000000000000000}, 'prior': (0, 0)}})>], [(<scale_info::0(value=Cwvu9hqzqCMMK8yLVAcSKPjMDs2yQrrfEpAV3ZVJqpQz7RJ)>, <U16(value=1)>), <scale_info::600(value={'Casting': {'votes': [(8, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (14, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (17, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}}), (23, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}}), (24, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}}), (34, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}}), (42, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}}), (43, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}}), (49, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (53, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (85, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (118, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (130, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (167, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (219, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (230, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}}), (232, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}})], 'delegations': {'votes': 57000000000000000, 'capital': 57000000000000000}, 'prior': (0, 0)}})>], [(<scale_info::0(value=Cwvu9hqzqCMMK8yLVAcSKPjMDs2yQrrfEpAV3ZVJqpQz7RJ)>, <U16(value=20)>), <scale_info::600(value={'Casting': {'votes': [(15, {'Standard': {'vote': {'aye': True, 'conviction': 'None'}, 'balance': 50000000000}}), (89, {'Standard': {'vote': {'aye': True, 'conviction': 'Locked1x'}, 'balance': 50000000000}})], 'delegations': {'votes': 57000000000000000, 'capital': 57000000000000000}, 'prior': (0, 0)}})>], [(<scale_info::0(value=Dcu6mYmwZjGkYJt43BJvuWnxGUZfsDZUos3xL4hKYMRWaT7)>, <U16(value=0)>), <scale_info::600(value={'Delegating': {'balance': 100000000000, 'target': 'Day71GSJAxUUiFic8bVaWoAczR3Ue3jNonBZthVHp2BKzyJ', 'conviction': 'None', 'delegations': {'votes': 0, 'capital': 0}, 'prior': (16871527, 113000000000)}})>], [(<scale_info::0(value=Dcu6mYmwZjGkYJt43BJvuWnxGUZfsDZUos3xL4hKYMRWaT7)>, <U16(value=14)>), <scale_info::600(value={'Delegating': {'balance': 100000000000, 'target': 'Day71GSJAxUUiFic8bVaWoAczR3Ue3jNonBZthVHp2BKzyJ', 'conviction': 'None', 'delegations': {'votes': 0, 'capital': 0}, 'prior': (16871527, 113000000000)}})>], [(<scale_info::0(value=Dcu6mYmwZjGkYJt43BJvuWnxGUZfsDZUos3xL4hKYMRWaT7)>, <U16(value=31)>), <scale_info::600(value={'Delegating': {'balance': 100000000000, 'target': 'Day71GSJAxUUiFic8bVaWoAczR3Ue3jNonBZthVHp2BKzyJ', 'conviction': 'None', 'delegations': {'votes': 0, 'capital': 0}, 'prior': (16871527, 113000000000)}})>], [(<scale_info::0(value=Dcu6mYmwZjGkYJt43BJvuWnxGUZfsDZUos3xL4hKYMRWaT7)>, <U16(value=21)>), <scale_info::600(value={'Delegating': {'balance': 100000000000, 'target': 'Day71GSJAxUUiFic8bVaWoAczR3Ue3jNonBZthVHp2BKzyJ', 'conviction': 'None', 'delegations': {'votes': 0, 'capital': 0}, 'prior': (16871527, 113000000000)}})>]]

Closes #350