def deserialize_uleb128_as_u32(self) -> int:
        value = 0
        for shift in range(0, 32, 7):
            byte = int.from_bytes(self.read(1), "little", signed=False)
            digit = byte & 0x7F
            value |= digit << shift
            if value > MAX_U32:
                raise st.DeserializationError(
                    "Overflow while parsing uleb128-encoded uint32 value")
            if digit == byte:
                if shift > 0 and digit == 0:
                    raise st.DeserializationError(
                        "Invalid uleb128 number (unexpected zero digit)")
                return value

        raise st.DeserializationError(
            "Overflow while parsing uleb128-encoded uint32 value")
 def check_that_key_slices_are_increasing(self, slice1: typing.Tuple[int,
                                                                     int],
                                          slice2: typing.Tuple[int, int]):
     key1 = bytes(self.input.getbuffer()[slice1[0]:slice1[1]])
     key2 = bytes(self.input.getbuffer()[slice2[0]:slice2[1]])
     if key1 >= key2:
         raise st.DeserializationError(
             "Serialized keys in a map must be ordered by increasing lexicographic order"
         )
Esempio n. 3
0
 def bcs_deserialize(input: bytes) -> 'BalanceResource':
     v, buffer = bcs.deserialize(input, BalanceResource)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 4
0
 def bcs_deserialize(input: bytes) -> 'ScriptFunction':
     v, buffer = bcs.deserialize(input, ScriptFunction)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 5
0
 def bcs_deserialize(input: bytes) -> 'SignedUserTransaction':
     v, buffer = bcs.deserialize(input, SignedUserTransaction)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 6
0
 def bcs_deserialize(input: bytes) -> 'Package':
     v, buffer = bcs.deserialize(input, Package)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 7
0
 def bcs_deserialize(input: bytes) -> 'ProposalCreatedEvent':
     v, buffer = bcs.deserialize(input, ProposalCreatedEvent)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 8
0
 def bcs_deserialize(input: bytes) -> 'TypeTag':
     v, buffer = bcs.deserialize(input, TypeTag)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 9
0
 def bcs_deserialize(input: bytes) -> 'ContractEventV0':
     v, buffer = bcs.deserialize(input, ContractEventV0)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 10
0
 def bcs_deserialize(input: bytes) -> 'AccountAddress':
     v, buffer = bcs.deserialize(input, AccountAddress)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 11
0
 def bcs_deserialize(input: bytes) -> 'ModuleId':
     v, buffer = bcs.deserialize(input, ModuleId)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 12
0
 def bcs_deserialize(input: bytes) -> 'Identifier':
     v, buffer = bcs.deserialize(input, Identifier)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 13
0
 def bcs_deserialize(input: bytes) -> 'KeyRotationCapabilityResource':
     v, buffer = bcs.deserialize(input, KeyRotationCapabilityResource)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 14
0
 def bcs_deserialize(input: bytes) -> 'GeneralMetadata':
     v, buffer = bcs.deserialize(input, GeneralMetadata)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 15
0
 def bcs_deserialize(input: bytes) -> 'EventKey':
     v, buffer = bcs.deserialize(input, EventKey)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 16
0
 def bcs_deserialize(input: bytes) -> 'DataPath':
     v, buffer = bcs.deserialize(input, DataPath)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 17
0
 def bcs_deserialize(input: bytes) -> 'TransactionPayload':
     v, buffer = bcs.deserialize(input, TransactionPayload)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 18
0
 def deserialize_len(self) -> int:
     value = self.deserialize_uleb128_as_u32()
     if value > MAX_LENGTH:
         raise st.DeserializationError(
             "Length exceeds the maximum supported value.")
     return value
Esempio n. 19
0
 def bcs_deserialize(input: bytes) -> 'TravelRuleMetadataV0':
     v, buffer = bcs.deserialize(input, TravelRuleMetadataV0)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 20
0
 def bcs_deserialize(input: bytes) -> 'WriteOp':
     v, buffer = bcs.deserialize(input, WriteOp)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 21
0
 def bcs_deserialize(input: bytes) -> 'MultiEd25519Signature':
     v, buffer = bcs.deserialize(input, MultiEd25519Signature)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 22
0
 def bcs_deserialize(input: bytes) -> 'ChangeSet':
     v, buffer = bcs.deserialize(input, ChangeSet)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 23
0
 def bcs_deserialize(input: bytes) -> 'NewBlockEvent':
     v, buffer = bcs.deserialize(input, NewBlockEvent)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v
Esempio n. 24
0
 def bcs_deserialize(input: bytes) -> 'UnstructuredBytesMetadata':
     v, buffer = bcs.deserialize(input, UnstructuredBytesMetadata)
     if buffer:
         raise st.DeserializationError("Some input bytes were not read")
     return v