示例#1
0
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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
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
示例#5
0
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)
示例#6
0
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)
示例#7
0
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)
示例#8
0
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)
示例#9
0
def write_action_deleteauth(w: Writer, msg: EosActionDeleteAuth) -> None:
    write_uint64_le(w, msg.account)
    write_uint64_le(w, msg.permission)
示例#10
0
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)
示例#11
0
def write_action_deleteauth(w: bytearray, msg: EosActionDeleteAuth):
    write_uint64_le(w, msg.account)
    write_uint64_le(w, msg.permission)
示例#12
0
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)
示例#13
0
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)
示例#14
0
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)
示例#15
0
def write_action_refund(w: bytearray, msg: EosActionRefund):
    write_uint64_le(w, msg.owner)
示例#16
0
def write_action_sellram(w: bytearray, msg: EosActionSellRam):
    write_uint64_le(w, msg.account)
    write_uint64_le(w, msg.bytes)
示例#17
0
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)
示例#18
0
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)
示例#19
0
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)
示例#20
0
def write_action_sellram(w: Writer, msg: EosActionSellRam) -> None:
    write_uint64_le(w, msg.account)
    write_uint64_le(w, msg.bytes)
示例#21
0
def write_asset(w: Writer, asset: EosAsset) -> None:
    write_uint64_le(w, asset.amount)
    write_uint64_le(w, asset.symbol)
示例#22
0
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)
示例#23
0
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)
示例#24
0
def write_asset(w: bytearray, asset: EosAsset) -> int:
    write_uint64_le(w, asset.amount)
    write_uint64_le(w, asset.symbol)
示例#25
0
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)
示例#26
0
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)
示例#27
0
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)
示例#28
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
示例#29
0
def write_action_refund(w: Writer, msg: EosActionRefund) -> None:
    write_uint64_le(w, msg.owner)
示例#30
0
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)