# 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.Approval events.
class TokenApproval(object):
    __slots__ = ["_tab"]

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

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

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

    # Primary key: Transaction hash.
    # TokenApproval
    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

    # TokenApproval
    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

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

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

    # Block hash.
    # TokenApproval
    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

    # TokenApproval
    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

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

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

    # XBR token sending address.
    # TokenApproval
    def OwnerAddress(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

    # TokenApproval
    def OwnerAddressAsNumpy(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

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

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

    # XBR token receiving address.
    # TokenApproval
    def SpenderAddress(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

    # TokenApproval
    def SpenderAddressAsNumpy(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

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

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

    # XBR token transferred.
    # TokenApproval
    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

    # TokenApproval
    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

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

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


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


def Start(builder):
    TokenApprovalStart(builder)


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


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


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


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


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


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


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


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


def TokenApprovalAddOwnerAddress(builder, ownerAddress):
    builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(ownerAddress), 0)


def AddOwnerAddress(builder, ownerAddress):
    TokenApprovalAddOwnerAddress(builder, ownerAddress)


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


def StartOwnerAddressVector(builder, numElems: int) -> int:
    return TokenApprovalStartOwnerAddressVector(builder, numElems)


def TokenApprovalAddSpenderAddress(builder, spenderAddress):
    builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(spenderAddress), 0)


def AddSpenderAddress(builder, spenderAddress):
    TokenApprovalAddSpenderAddress(builder, spenderAddress)


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


def StartSpenderAddressVector(builder, numElems: int) -> int:
    return TokenApprovalStartSpenderAddressVector(builder, numElems)


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


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


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


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


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


def End(builder):
    return TokenApprovalEnd(builder)
