Skip to content

Commit

Permalink
Add set block chain params, fix register and rex deposit functions
Browse files Browse the repository at this point in the history
  • Loading branch information
guilledk committed Sep 26, 2024
1 parent 7ccde7e commit 8d9a8ff
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = 'py-leap'
version = '0.1a25'
version = '0.1a26'
packages = [{include = 'leap', from='src'}]
description = ''
authors = ['Guillermo Rodriguez <[email protected]>']
Expand Down
22 changes: 18 additions & 4 deletions src/leap/cleos.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,13 @@ def download_contract(
with open(download_location / f'{local_name}.abi', 'w+') as abi_file:
abi_file.write(json_module.dumps(abi))

def set_blockchain_parameters(self, params: dict):
return self.push_action(
'eosio',
'setparams',
[params],
'eosio'
)

def boot_sequence(
self,
Expand Down Expand Up @@ -1561,7 +1568,8 @@ def rex_deposit(
'eosio',
'deposit',
[owner, quantity],
owner
owner,
key=self.private_keys[owner]
)

def rex_buy(
Expand Down Expand Up @@ -1600,19 +1608,24 @@ def delegate_bandwidth(
def register_producer(
self,
producer: str,
key: str | None = None,
url: str = '',
location: int = 0
):
if not key:
key = self.keys[producer]

return self.push_action(
'eosio',
'regproducer',
[
producer,
self.keys[producer],
key,
url,
location
],
producer
producer,
key=self.private_keys[producer]
)

def vote_producers(
Expand All @@ -1625,7 +1638,8 @@ def vote_producers(
'eosio',
'voteproducer',
[voter, proxy, producers],
voter
voter,
key=self.private_keys[voter]
)

def claim_rewards(
Expand Down
19 changes: 19 additions & 0 deletions src/leap/protocol/ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,25 @@ def pack_tstamp(self, v):
def unpack_tstamp(self):
self.unpack_uint64()

def pack_blockchain_parameters(self, v):
self.pack_uint64(v["max_block_net_usage"])
self.pack_uint32(v["target_block_net_usage_pct"])
self.pack_uint32(v["max_transaction_net_usage"])
self.pack_uint32(v["base_per_transaction_net_usage"])
self.pack_uint32(v["net_usage_leeway"])
self.pack_uint32(v["context_free_discount_net_usage_num"])
self.pack_uint32(v["context_free_discount_net_usage_den"])
self.pack_uint32(v["max_block_cpu_usage"])
self.pack_uint32(v["target_block_cpu_usage_pct"])
self.pack_uint32(v["max_transaction_cpu_usage"])
self.pack_uint32(v["min_transaction_cpu_usage"])
self.pack_uint32(v["max_transaction_lifetime"])
self.pack_uint32(v["deferred_trx_expiration_window"])
self.pack_uint32(v["max_transaction_delay"])
self.pack_uint32(v["max_inline_action_size"])
self.pack_uint16(v["max_inline_action_depth"])
self.pack_uint16(v["max_authority_depth"])

def pack_handshake_message(self, v):
self.pack_uint16(v.network_version)
self.pack_chain_id_type(v.chain_id)
Expand Down

0 comments on commit 8d9a8ff

Please sign in to comment.