Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ss58_decode_account_index(address, valid_address_type=42):
account_index_bytes = ss58_decode(address, valid_address_type)
if len(account_index_bytes) == 2:
return U8(ScaleBytes('0x{}'.format(account_index_bytes))).decode()
if len(account_index_bytes) == 4:
return U16(ScaleBytes('0x{}'.format(account_index_bytes))).decode()
if len(account_index_bytes) == 8:
return U32(ScaleBytes('0x{}'.format(account_index_bytes))).decode()
if len(account_index_bytes) == 16:
return U64(ScaleBytes('0x{}'.format(account_index_bytes))).decode()
else:
raise ValueError("Invalid account index length")
def ss58_decode_account_index(address, valid_address_type=None):
account_index_bytes = ss58_decode(address, valid_address_type)
if len(account_index_bytes) == 2:
return U8(ScaleBytes('0x{}'.format(account_index_bytes))).decode()
if len(account_index_bytes) == 4:
return U16(ScaleBytes('0x{}'.format(account_index_bytes))).decode()
if len(account_index_bytes) == 8:
return U32(ScaleBytes('0x{}'.format(account_index_bytes))).decode()
if len(account_index_bytes) == 16:
return U64(ScaleBytes('0x{}'.format(account_index_bytes))).decode()
else:
raise ValueError("Invalid account index length")
def ss58_encode_account_index(account_index, address_type=42):
if 0 <= account_index <= 2**8 - 1:
account_idx_encoder = U8()
elif 2**8 <= account_index <= 2**16 - 1:
account_idx_encoder = U16()
elif 2**16 <= account_index <= 2**32 - 1:
account_idx_encoder = U32()
elif 2**32 <= account_index <= 2**64 - 1:
account_idx_encoder = U64()
else:
raise ValueError("Value too large for an account index")
return ss58_encode(account_idx_encoder.encode(account_index).data, address_type)
return self.index == 2
def is_twox128(self):
return self.index == 3
def is_twox256(self):
return self.index == 4
def is_twox64_concat(self):
return self.index == 5
def is_identity(self):
return self.index == 6
class LockPeriods(U8):
pass
class SessionKey(H256):
pass
class PrefabWasmModule(Struct):
type_string = 'wasm::PrefabWasmModule'
type_mapping = (
('scheduleVersion', 'Compact'),
('initial', 'Compact'),
('maximum', 'Compact'),
('_reserved', 'Option'),
('code', 'Bytes'),
def ss58_encode_account_index(account_index, address_type=42):
if 0 <= account_index <= 2**8 - 1:
account_idx_encoder = U8()
elif 2**8 <= account_index <= 2**16 - 1:
account_idx_encoder = U16()
elif 2**16 <= account_index <= 2**32 - 1:
account_idx_encoder = U32()
elif 2**32 <= account_index <= 2**64 - 1:
account_idx_encoder = U64()
else:
raise ValueError("Value too large for an account index")
return ss58_encode(account_idx_encoder.encode(account_index).data, address_type)
DEFAULT_CONVICTION = 0b00000000
value_list = ['None', 'Locked1x', 'Locked2x', 'Locked3x', 'Locked4x', 'Locked5x', 'Locked6x']
class GenericBlock(ScaleType):
# TODO implement generic block type
def process(self):
raise NotImplementedError()
def process_encode(self, value):
raise NotImplementedError()
class GenericVote(U8):
pass
class GenericCall(ScaleType):
type_string = "Box"
def __init__(self, data, **kwargs):
self.call_index = None
self.call_function = None
self.call_args = []
self.call_module = None
super().__init__(data, **kwargs)
def process(self):