# automatically generated by the FlatBuffers compiler, do not modify

# namespace: xbr

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


# This table stores XBRToken.Transfer events.
class TokenTransfer(object):
    __slots__ = ["_tab"]

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = TokenTransfer()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsTokenTransfer(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)

    # TokenTransfer
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Primary key: Transaction hash.
    # TokenTransfer
    def TxHash(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # TokenTransfer
    def TxHashAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # TokenTransfer
    def TxHashLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TokenTransfer
    def TxHashIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        return o == 0

    # Block hash.
    # TokenTransfer
    def BlockHash(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # TokenTransfer
    def BlockHashAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # TokenTransfer
    def BlockHashLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TokenTransfer
    def BlockHashIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

    # XBR token sending address.
    # TokenTransfer
    def FromAddress(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # TokenTransfer
    def FromAddressAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # TokenTransfer
    def FromAddressLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TokenTransfer
    def FromAddressIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        return o == 0

    # XBR token receiving address.
    # TokenTransfer
    def ToAddress(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # TokenTransfer
    def ToAddressAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # TokenTransfer
    def ToAddressLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TokenTransfer
    def ToAddressIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        return o == 0

    # XBR token transferred.
    # TokenTransfer
    def Value(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # TokenTransfer
    def ValueAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # TokenTransfer
    def ValueLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TokenTransfer
    def ValueIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        return o == 0


def TokenTransferStart(builder):
    builder.StartObject(5)


def Start(builder):
    TokenTransferStart(builder)


def TokenTransferAddTxHash(builder, txHash):
    builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(txHash), 0)


def AddTxHash(builder, txHash):
    TokenTransferAddTxHash(builder, txHash)


def TokenTransferStartTxHashVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartTxHashVector(builder, numElems: int) -> int:
    return TokenTransferStartTxHashVector(builder, numElems)


def TokenTransferAddBlockHash(builder, blockHash):
    builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(blockHash), 0)


def AddBlockHash(builder, blockHash):
    TokenTransferAddBlockHash(builder, blockHash)


def TokenTransferStartBlockHashVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartBlockHashVector(builder, numElems: int) -> int:
    return TokenTransferStartBlockHashVector(builder, numElems)


def TokenTransferAddFromAddress(builder, fromAddress):
    builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(fromAddress), 0)


def AddFromAddress(builder, fromAddress):
    TokenTransferAddFromAddress(builder, fromAddress)


def TokenTransferStartFromAddressVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartFromAddressVector(builder, numElems: int) -> int:
    return TokenTransferStartFromAddressVector(builder, numElems)


def TokenTransferAddToAddress(builder, toAddress):
    builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(toAddress), 0)


def AddToAddress(builder, toAddress):
    TokenTransferAddToAddress(builder, toAddress)


def TokenTransferStartToAddressVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartToAddressVector(builder, numElems: int) -> int:
    return TokenTransferStartToAddressVector(builder, numElems)


def TokenTransferAddValue(builder, value):
    builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(value), 0)


def AddValue(builder, value):
    TokenTransferAddValue(builder, value)


def TokenTransferStartValueVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartValueVector(builder, numElems: int) -> int:
    return TokenTransferStartValueVector(builder, numElems)


def TokenTransferEnd(builder):
    return builder.EndObject()


def End(builder):
    return TokenTransferEnd(builder)
