diff --git a/tonsdk_ng/types/_builder.py b/tonsdk_ng/types/_builder.py index fec55fa..20c1b78 100644 --- a/tonsdk_ng/types/_builder.py +++ b/tonsdk_ng/types/_builder.py @@ -1,6 +1,7 @@ from ._address import Address from ._bit_string import BitString from ._cell import Cell +from ._slice import Slice class Builder: @@ -30,6 +31,22 @@ def store_maybe_ref(self, src: Cell | None) -> "Builder": return self + def store_slice(self, src: Slice) -> "Builder": + if len(self.refs) + len(src.refs) > 4: + raise ValueError("refs overflow") + self.bits.write_bit_array(src.bits) + for i in range(src.ref_offset, len(src.refs)): + self.store_ref(src.refs[i]) + return self + + def store_maybe_slice(self, src: Slice | None) -> "Builder": + if src is not None: + self.bits.write_bit(1) + self.store_slice(src) + else: + self.bits.write_bit(0) + return self + def store_bit(self, value: int) -> "Builder": self.bits.write_bit(value) return self