# automatically generated by the FlatBuffers compiler, do not modify

# namespace: xbrnetwork

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


class UserKey(object):
    __slots__ = ["_tab"]

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

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

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

    # User key - a Ed25519 public key - for authenticating using WAMP-cryptosign.
    # UserKey
    def Pubkey(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

    # UserKey
    def PubkeyAsNumpy(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

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

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

    # Timestamp (epoch time in ns) of initial creation of this record.
    # UserKey
    def Created(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # ID of user account this user key is owned by.
    # UserKey
    def Owner(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

    # UserKey
    def OwnerAsNumpy(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

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

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


def UserKeyStart(builder):
    builder.StartObject(3)


def Start(builder):
    UserKeyStart(builder)


def UserKeyAddPubkey(builder, pubkey):
    builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pubkey), 0)


def AddPubkey(builder, pubkey):
    UserKeyAddPubkey(builder, pubkey)


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


def StartPubkeyVector(builder, numElems: int) -> int:
    return UserKeyStartPubkeyVector(builder, numElems)


def UserKeyAddCreated(builder, created):
    builder.PrependUint64Slot(1, created, 0)


def AddCreated(builder, created):
    UserKeyAddCreated(builder, created)


def UserKeyAddOwner(builder, owner):
    builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(owner), 0)


def AddOwner(builder, owner):
    UserKeyAddOwner(builder, owner)


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


def StartOwnerVector(builder, numElems: int) -> int:
    return UserKeyStartOwnerVector(builder, numElems)


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


def End(builder):
    return UserKeyEnd(builder)
