def write_action_common(w: Writer, msg: EosActionCommon) -> None: write_uint64_le(w, msg.account) write_uint64_le(w, msg.name) write_variant32(w, len(msg.authorization)) for authorization in msg.authorization: write_uint64_le(w, authorization.actor) write_uint64_le(w, authorization.permission)
def write_action_common(hasher: HashWriter, msg: EosActionCommon): write_uint64_le(hasher, msg.account) write_uint64_le(hasher, msg.name) write_variant32(hasher, len(msg.authorization)) for authorization in msg.authorization: write_uint64_le(hasher, authorization.actor) write_uint64_le(hasher, authorization.permission)
def write_auth(w: Writer, auth: EosAuthorization) -> None: write_uint32_le(w, auth.threshold) write_variant32(w, len(auth.keys)) for key in auth.keys: write_variant32(w, key.type) write_bytes_unchecked(w, key.key) write_uint16_le(w, key.weight) write_variant32(w, len(auth.accounts)) for account in auth.accounts: write_uint64_le(w, account.account.actor) write_uint64_le(w, account.account.permission) write_uint16_le(w, account.weight) write_variant32(w, len(auth.waits)) for wait in auth.waits: write_uint32_le(w, wait.wait_sec) write_uint16_le(w, wait.weight)
def serialize_tx_common( common: NEMTransactionCommon, public_key: bytes, transaction_type: int, version: int | None = None, ) -> bytearray: w = bytearray() write_uint32_le(w, transaction_type) if version is None: version = common.network << 24 | 1 write_uint32_le(w, version) write_uint32_le(w, common.timestamp) write_bytes_with_len(w, public_key) write_uint64_le(w, common.fee) write_uint32_le(w, common.deadline) return w
def write_auth(w: Writer, auth: EosAuthorization) -> None: write_uint32_le(w, auth.threshold) write_uvarint(w, len(auth.keys)) for key in auth.keys: if key.key is None: raise wire.DataError("Key must be provided explicitly.") write_uvarint(w, key.type) write_bytes_fixed(w, key.key, 33) write_uint16_le(w, key.weight) write_uvarint(w, len(auth.accounts)) for account in auth.accounts: write_uint64_le(w, account.account.actor) write_uint64_le(w, account.account.permission) write_uint16_le(w, account.weight) write_uvarint(w, len(auth.waits)) for wait in auth.waits: write_uint32_le(w, wait.wait_sec) write_uint16_le(w, wait.weight)
def write_action_unlinkauth(w: Writer, msg: EosActionLinkAuth) -> None: write_uint64_le(w, msg.account) write_uint64_le(w, msg.code) write_uint64_le(w, msg.type)
def write_action_newaccount(w: Writer, msg: EosActionNewAccount) -> None: write_uint64_le(w, msg.creator) write_uint64_le(w, msg.name) write_auth(w, msg.owner) write_auth(w, msg.active)
def write_action_updateauth(w: Writer, msg: EosActionUpdateAuth) -> None: write_uint64_le(w, msg.account) write_uint64_le(w, msg.permission) write_uint64_le(w, msg.parent) write_auth(w, msg.auth)
def write_action_deleteauth(w: Writer, msg: EosActionDeleteAuth) -> None: write_uint64_le(w, msg.account) write_uint64_le(w, msg.permission)
def write_action_transfer(w: bytearray, msg: EosActionTransfer): write_uint64_le(w, msg.sender) write_uint64_le(w, msg.receiver) write_asset(w, msg.quantity) write_variant32(w, len(msg.memo)) write_bytes(w, msg.memo)
def write_action_deleteauth(w: bytearray, msg: EosActionDeleteAuth): write_uint64_le(w, msg.account) write_uint64_le(w, msg.permission)
def write_action_buyram(w: Writer, msg: EosActionBuyRam) -> None: write_uint64_le(w, msg.payer) write_uint64_le(w, msg.receiver) write_asset(w, msg.quantity)
def write_action_unlinkauth(w: bytearray, msg: EosActionLinkAuth): write_uint64_le(w, msg.account) write_uint64_le(w, msg.code) write_uint64_le(w, msg.type)
def write_action_undelegate(w: bytearray, msg: EosActionUndelegate): write_uint64_le(w, msg.sender) write_uint64_le(w, msg.receiver) write_asset(w, msg.net_quantity) write_asset(w, msg.cpu_quantity)
def write_action_refund(w: bytearray, msg: EosActionRefund): write_uint64_le(w, msg.owner)
def write_action_sellram(w: bytearray, msg: EosActionSellRam): write_uint64_le(w, msg.account) write_uint64_le(w, msg.bytes)
def write_action_buyrambytes(w: bytearray, msg: EosActionBuyRamBytes): write_uint64_le(w, msg.payer) write_uint64_le(w, msg.receiver) write_uint32_le(w, msg.bytes)
def write_action_buyram(w: bytearray, msg: EosActionBuyRam): write_uint64_le(w, msg.payer) write_uint64_le(w, msg.receiver) write_asset(w, msg.quantity)
def write_action_newaccount(w: bytearray, msg: EosActionNewAccount): write_uint64_le(w, msg.creator) write_uint64_le(w, msg.name) write_auth(w, msg.owner) write_auth(w, msg.active)
def write_action_sellram(w: Writer, msg: EosActionSellRam) -> None: write_uint64_le(w, msg.account) write_uint64_le(w, msg.bytes)
def write_asset(w: Writer, asset: EosAsset) -> None: write_uint64_le(w, asset.amount) write_uint64_le(w, asset.symbol)
def write_action_undelegate(w: Writer, msg: EosActionUndelegate) -> None: write_uint64_le(w, msg.sender) write_uint64_le(w, msg.receiver) write_asset(w, msg.net_quantity) write_asset(w, msg.cpu_quantity)
def write_action_transfer(w: Writer, msg: EosActionTransfer) -> None: write_uint64_le(w, msg.sender) write_uint64_le(w, msg.receiver) write_asset(w, msg.quantity) write_variant32(w, len(msg.memo)) write_bytes_unchecked(w, msg.memo)
def write_asset(w: bytearray, asset: EosAsset) -> int: write_uint64_le(w, asset.amount) write_uint64_le(w, asset.symbol)
def write_action_buyrambytes(w: Writer, msg: EosActionBuyRamBytes) -> None: write_uint64_le(w, msg.payer) write_uint64_le(w, msg.receiver) write_uint32_le(w, msg.bytes)
def write_action_transfer(w: Writer, msg: EosActionTransfer) -> None: write_uint64_le(w, msg.sender) write_uint64_le(w, msg.receiver) write_asset(w, msg.quantity) write_bytes_prefixed(w, msg.memo)
def write_action_delegate(w: Writer, msg: EosActionDelegate) -> None: write_uint64_le(w, msg.sender) write_uint64_le(w, msg.receiver) write_asset(w, msg.net_quantity) write_asset(w, msg.cpu_quantity) write_uint8(w, 1 if msg.transfer else 0)
def sstxcommitment_pkh(pkh: bytes, amount: int) -> bytes: w = utils.empty_bytearray(30) write_bytes_fixed(w, pkh, 20) write_uint64_le(w, amount) write_bytes_fixed(w, b"\x00\x58", 2) # standard fee limits return w
def write_action_refund(w: Writer, msg: EosActionRefund) -> None: write_uint64_le(w, msg.owner)
def write_action_voteproducer(w: Writer, msg: EosActionVoteProducer) -> None: write_uint64_le(w, msg.voter) write_uint64_le(w, msg.proxy) write_variant32(w, len(msg.producers)) for producer in msg.producers: write_uint64_le(w, producer)