Ejemplo n.º 1
0
class NationalIdObject:
    # Indicates the national ID value - for example, a social security number
    id_value: str
    # Two-letter country code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
    country: typing.Optional[str] = datafield(default=None)
    # Indicates the type of the ID
    type: typing.Optional[str] = datafield(default=None)
Ejemplo n.º 2
0
class CommandRequestObject:
    # A unique identifier for the Command.
    cid: str = datafield(metadata={"valid-values": UUID_REGEX})
    # A string representing the type of Command contained in the request.
    command_type: str
    command: dict  # pyre-ignore
    _ObjectType: str = datafield(default="CommandRequestObject", metadata={"valid-values": ["CommandRequestObject"]})
Ejemplo n.º 3
0
class PaymentActionObject:
    amount: int
    currency: str
    action: str = datafield(default="charge",
                            metadata={"valid-values": ["charge"]})
    # Unix timestamp (seconds) indicating the time that the payment Command was created.
    timestamp: int = datafield(default_factory=lambda: int(time.time()))
Ejemplo n.º 4
0
class PaymentActorObject:
    address: str = datafield(metadata={"write_once": True})
    status: StatusObject
    kyc_data: typing.Optional[KycDataObject] = datafield(
        default=None, metadata={"write_once": True})
    metadata: typing.Optional[typing.List[str]] = datafield(default=None)
    additional_kyc_data: typing.Optional[str] = datafield(
        default=None, metadata={"write_once": True})
Ejemplo n.º 5
0
class CommandResponseObject:
    # Either success or failure.
    status: str = datafield(metadata={"valid-values": [CommandResponseStatus.success, CommandResponseStatus.failure]})
    # The fixed string CommandResponseObject.
    _ObjectType: str = datafield(default="CommandResponseObject", metadata={"valid-values": ["CommandResponseObject"]})
    # Details on errors when status == "failure"
    error: typing.Optional[OffChainErrorObject] = datafield(default=None)
    # The Command identifier to which this is a response.
    cid: typing.Optional[str] = datafield(default=None)
Ejemplo n.º 6
0
class OffChainErrorObject:
    # Either "command_error" or "protocol_error".
    type: str
    # The error code of the corresponding error
    code: str
    # The field on which this error occurred
    field: typing.Optional[str] = datafield(default=None)
    # Additional details about this error
    message: typing.Optional[str] = datafield(default=None)
Ejemplo n.º 7
0
class Register():
    """ Models a register """

    name: str = ""
    """ The abbreviated/symbolic/accronym name for this register """

    long_name: str = ""
    """ The non-abbreviated/spelled out name for this register """

    purpose: str = ""
    """ A description of this register's purpose """

    size: int = 64
    """ The size (in bits) of this register """

    arch: str = "none"
    """ The name of the architecture this register belongs to """

    is_internal: bool = False
    """ True if the register is internal to a CPU """

    is_optional: bool = False
    """ True if this register is an optional feature of the architecture """

    is_indexed: bool = False
    """ True if the register has many instances, accessable via an index """

    access_mechanisms: Dict[str, List[AbstractAccessMechanism]] \
        = datafield(default_factory= lambda: {})
    """ Access mechanisms by which this register is readable/writable """

    fieldsets: List[Fieldset] = datafield(default_factory=lambda: [])
    """ List of fieldsets that define all fields/bitfields in this register """
    def is_valid(self):
        for fs in self.fieldsets:
            if not fs.is_valid(): return False

        for am_list in self.access_mechanisms.values():
            for am in am_list:
                if not am.is_valid(): return False

        return True

    def is_readable(self):
        for am_list in self.access_mechanisms.values():
            for am in am_list:
                if am.is_read(): return True

        return False

    def is_writeable(self):
        for am_list in self.access_mechanisms.values():
            for am in am_list:
                if am.is_write(): return True

        return False
Ejemplo n.º 8
0
class PaymentObject:
    reference_id: str = datafield(metadata={"valid-values": UUID_REGEX})
    sender: PaymentActorObject
    receiver: PaymentActorObject
    action: PaymentActionObject = datafield(metadata={"write_once": True})
    original_payment_reference_id: typing.Optional[str] = datafield(
        default=None, metadata={"immutable": True})
    recipient_signature: typing.Optional[str] = datafield(
        default=None, metadata={"write_once": True})
    description: typing.Optional[str] = datafield(
        default=None, metadata={"write_once": True})
Ejemplo n.º 9
0
class PrioritizedItem:
    table: str = datafield(compare=False)
    tuple: Any = datafield(compare=False)
    field: str = datafield(compare=False, default='')
    value: Any = datafield(compare=False, default='')
    schema: str = datafield(compare=False, default='experiment')
    replace: bool = datafield(compare=False, default=False)
    block: bool = datafield(compare=False, default=False)
    priority: int = datafield(default=50)
    error: bool = datafield(compare=False, default=False)
Ejemplo n.º 10
0
class CommandRequestObject:
    # A unique identifier for the Command.
    cid: str = datafield(metadata={"valid-values": UUID_REGEX})
    # A string representing the type of Command contained in the request.
    command_type: str = datafield(
        metadata={
            "valid-values": [
                CommandType.PaymentCommand,
                CommandType.FundPullPreApprovalCommand
            ]
        })
    command: PaymentCommandObject
    _ObjectType: str = datafield(
        default="CommandRequestObject",
        metadata={"valid-values": ["CommandRequestObject"]})
Ejemplo n.º 11
0
class ARMv8ARegister(Register):
    """ Models a register in the ARMv8-A architecture profile """

    execution_state: str = None
    """ The execution state this register belongs to: """
    """ None = no associated execution state (i.e. memory mapped) """
    """ aarch32 = ARM 32-bit execution state """
    """ aarch64 = ARM 64-bit execution state """

    is_banked: bool = False
    """ True if the register is banked (has copies per exception level) """

    arch: str = "armv8-a"

    access_mechanisms: Dict[str, List[AbstractAccessMechanism]] \
        = datafield(default_factory= lambda: {
            "mrc": [],
            "mcr": [],
            "mrrc": [],
            "mcrr": [],
            "ldr": [],
            "str": [],
            "msr": [],
            "mrs_register": [],
            "mrs_banked": [],
            "msr_register": [],
            "msr_banked": [],
            "msr_immediate": [],
            "vmsr": [],
            "vmrs": [],
        })
Ejemplo n.º 12
0
class StatusObject:
    # Status of the payment from the perspective of this actor. Required
    status: str = datafield(
        metadata={
            "valid-values": [
                Status.none,
                Status.needs_kyc_data,
                Status.ready_for_settlement,
                Status.abort,
                Status.soft_match,
            ]
        })
    # In the case of an abort status, this field may be used to describe the reason for the abort.
    abort_code: typing.Optional[str] = datafield(default=None)
    # Additional details about this error. To be used only when code is populated
    abort_message: typing.Optional[str] = datafield(default=None)
Ejemplo n.º 13
0
class ExecutionContext():
    """ Models the context under which an instruction may be executed """

    execution_state: str = ""
    """ The name of the execution state an instruction is executable in """

    logical_inputs: List[LogicalOperand] = datafield(
        default_factory=lambda: [])
    """ List of logical values this instruction takes as inputs """

    logical_ouputs: List[LogicalOperand] = datafield(
        default_factory=lambda: [])
    """ List of logical values this instruction produces as outputs """

    register_operands: List[RegisterOperand] = datafield(
        default_factory=lambda: [])
    """ List of registers this instruction operates on """
Ejemplo n.º 14
0
class PrioritizedItem:
    table: str = datafield(compare=False)
    tuple: Any = datafield(compare=False)
    field: str = datafield(compare=False, default='')
    value: Any = datafield(compare=False, default='')
    schema: str = datafield(compare=False, default='lab')
    replace: bool = datafield(compare=False, default=False)
    priority: int = datafield(default=50)
Ejemplo n.º 15
0
class ReferenceIDCommandResultObject:
    # ReferenceIDCommandResponse: Receiver's onchain account identifier
    receiver_address: str
    _ObjectType: str = datafield(
        default=OffChainCommandResponseResultType.ReferenceIDCommandResponse,
        metadata={
            "valid-values": [
                OffChainCommandResponseResultType.ReferenceIDCommandResponse,
            ]
        },
    )
Ejemplo n.º 16
0
class GenericRegister(Register):
    """ Models a generic register that does not belong to a particular """
    """ microarchitecture """

    arch: str = "generic"

    access_mechanisms: Dict[str, List[AbstractAccessMechanism]] \
        = datafield(default_factory= lambda: {
            "read": [],
            "write": [],
        })
Ejemplo n.º 17
0
class x86_64Register(Register):
    """ Models a register in the Intel x86_64 architecture """

    arch: str = "x86_64"

    execution_states: Dict[str, bool] \
        = datafield(default_factory= lambda: {
            "real_mode": False,
            "protected_mode": False,
            "64bit_mode": False,
            "compatibility_mode": False,
            "virtual_8086": False,
        })

    arch_variants: Dict[str, bool] \
        = datafield(default_factory= lambda: {
            "skylake": False,
            "goldmont": False,
            "kaby_lake": False,
            "coffee_lake": False,
            "goldmont_plus": False,
            "cannon_lake": False,
            "whiskey_lake": False,
            "amber_lake": False,
            "cascade_lake": False,
            "comet_lake": False,
            "ice_lake": False,
        })

    access_mechanisms: Dict[str, List[AbstractAccessMechanism]] \
        = datafield(default_factory= lambda: {
            "mov_read": [],
            "mov_write": [],
            "cpuid": [],
            "rdmsr": [],
            "wrmsr": [],
            "vmread": [],
            "vmwrite": [],
            "xgetbv": [],
            "xsetbv": [],
        })
Ejemplo n.º 18
0
class ReferenceIDCommandObject:
    # Sender's full DiemID
    sender: str
    # Sender's onchain account identifier with subaddress set to `None` or the zero subaddress
    sender_address: str
    # Receiver's full DiemID
    receiver: str
    # Reference ID of this transaction
    reference_id: str
    _ObjectType: str = datafield(
        default=CommandType.ReferenceIDCommand, metadata={"valid-values": [CommandType.ReferenceIDCommand]}
    )
Ejemplo n.º 19
0
class Instruction():
    """ Models an instruction """

    name: str = ""
    """ The abbreviated/symbolic/accronym name for this instruction """

    long_name: str = ""
    """ The non-abbreviated/spelled out name for this instruction """

    purpose: str = ""
    """ A description of this instruction's purpose """

    execution_contexts: List[ExecutionContext] = datafield(default_factory= lambda: [])
    """ List of execution contexts that define the usage of this instruction """
Ejemplo n.º 20
0
class KycDataObject:
    # Must be either “individual” or “entity”. Required.
    type: str = datafield(metadata={
        "valid-values":
        [KycDataObjectType.individual, KycDataObjectType.entity]
    })
    # Version identifier to allow modifications to KYC data Object without needing to bump version of entire API set. Set to 1
    payload_version: int = datafield(default=1, metadata={"valid-values": [1]})
    # Legal given name of the user for which this KYC data Object applies.
    given_name: typing.Optional[str] = datafield(default=None)
    # Legal surname of the user for which this KYC data Object applies.
    surname: typing.Optional[str] = datafield(default=None)
    # Physical address data for this account
    address: typing.Optional[AddressObject] = datafield(default=None)
    # Date of birth for the holder of this account. Specified as an ISO 8601 calendar date format: https:#en.wikipedia.org/wiki/ISO_8601
    dob: typing.Optional[str] = datafield(default=None)
    # Place of birth for this user. line1 and line2 fields should not be populated for this usage of the address Object
    place_of_birth: typing.Optional[AddressObject] = datafield(default=None)
    # National ID information for the holder of this account
    national_id: typing.Optional[NationalIdObject] = datafield(default=None)
    # Name of the legal entity. Used when subaddress represents a legal entity rather than an individual. KycDataObject should only include one of legal_entity_name OR given_name/surname
    legal_entity_name: typing.Optional[str] = datafield(default=None)
Ejemplo n.º 21
0
class AddressObject:
    # The city, district, suburb, town, or village
    city: typing.Optional[str] = datafield(default=None)
    # Two-letter country code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
    country: typing.Optional[str] = datafield(default=None)
    # Address line 1
    line1: typing.Optional[str] = datafield(default=None)
    # Address line 2 - apartment, unit, etc.
    line2: typing.Optional[str] = datafield(default=None)
    # ZIP or postal code
    postal_code: typing.Optional[str] = datafield(default=None)
    # State, county, province, region.
    state: typing.Optional[str] = datafield(default=None)
Ejemplo n.º 22
0
class FundPullPreApprovalCommandObject:
    _ObjectType: str = datafield(
        metadata={"valid-values": [CommandType.FundPullPreApprovalCommand]})
Ejemplo n.º 23
0
class PaymentCommandObject:
    _ObjectType: str = datafield(
        metadata={"valid-values": [CommandType.PaymentCommand]})
    payment: PaymentObject
Ejemplo n.º 24
0
 def copyfield(data):
     return datafield(default_factory=lambda: copy.deepcopy(data))