Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

canoser

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canoser - npm Package Compare versions

Comparing version
0.7.8
to
0.7.9
+1
-1
canoser.egg-info/PKG-INFO
Metadata-Version: 2.1
Name: canoser
Version: 0.7.8
Version: 0.7.9
Summary: A python implementation of the LCS(Libra Canonical Serialization) for the Libra network.

@@ -5,0 +5,0 @@ Home-page: https://github.com/yuan-xy/canoser-python.git

@@ -7,2 +7,4 @@

self.buffer = bytes(buffer)
if isinstance(buffer, bytearray):
self.buffer = bytes(buffer)
self.offset = offset

@@ -9,0 +11,0 @@ self.buffer_len = len(self.buffer)

@@ -60,2 +60,15 @@ import struct

@classmethod
def checked_add(cls, v1, v2):
#rust style api
cls.check_value(v1)
cls.check_value(v2)
try:
ret = v1+v2
cls.check_value(ret)
return ret
except TypeError:
return None
class Int8(IntType):

@@ -62,0 +75,0 @@ pack_str = "<b"

@@ -20,3 +20,3 @@ from canoser.base import Base

@classmethod
def new(cls, index, value):
def new_with_index_value(cls, index, value):
if not cls._enums:

@@ -82,5 +82,5 @@ raise TypeError(f'{cls} has no _enums defined.')

value = type_mapping(datatype).decode(cursor)
return cls.new(index, value)
return cls.new_with_index_value(index, value)
else:
return cls.new(index, None)
return cls.new_with_index_value(index, None)

@@ -87,0 +87,0 @@ @classmethod

@@ -19,3 +19,3 @@ from canoser.int_type import Uint32

@classmethod
def check_value(self, value):
def check_value(cls, value):
if not isinstance(value, str):

@@ -22,0 +22,0 @@ raise TypeError('value {} is not string'.format(value))

@@ -1,1 +0,1 @@

version = "0.7.8"
version = "0.7.9"
Metadata-Version: 2.1
Name: canoser
Version: 0.7.8
Version: 0.7.9
Summary: A python implementation of the LCS(Libra Canonical Serialization) for the Libra network.

@@ -5,0 +5,0 @@ Home-page: https://github.com/yuan-xy/canoser-python.git

@@ -17,2 +17,19 @@ from canoser import *

assert cursor.read_to_end() == b'\x04\x05'
assert cursor.is_finished() == True
def test_bytearray():
array = bytearray()
array.append(5)
array.append(2)
array.extend([3, 4])
cursor = Cursor(array)
assert cursor.read_u8() == 5
assert cursor.offset == 1
assert cursor.position() == cursor.offset
assert cursor.peek_bytes(3) == b'\x02\x03\x04'
assert cursor.offset == 1
assert cursor.read_bytes(2) == b'\x02\x03'
assert cursor.offset == 3
assert cursor.is_finished() == False
assert cursor.read_to_end() == b'\x04'
assert cursor.is_finished() == True

@@ -72,5 +72,5 @@ import pytest

def test_enum2():
e1 = Enum1.new(0, [5])
e1 = Enum1.new_with_index_value(0, [5])
e2 = Enum1('opt2', None)
assert Enum1.new(1, None) == Enum1('opt2')
assert Enum1.new_with_index_value(1, None) == Enum1('opt2')
assert Enum1.encode(e1) == b'\x00\x00\x00\x00\x01\x00\x00\x00\x05'

@@ -77,0 +77,0 @@ assert Enum1.encode(e2) == b'\x01\x00\x00\x00'

@@ -6,2 +6,6 @@ from canoser import *

def test_checked_add():
assert 255 == Uint8.checked_add(254, 1)
assert None == Uint8.checked_add(254, 2)
def test_str_to_int():

@@ -8,0 +12,0 @@ with pytest.raises(Exception):