Beispiel #1
0
 def from_json(cls, payload: Dict[str, Any]) -> "AccessedAddress":
     return AccessedAddress(
         utils.or_else(
             utils.optional_map(
                 payload["address"],
                 lambda addr: convert.hex_to_bytes(addr[2:])),
             bytes(),
         ),
         [
             utils.optional_map(key, lambda k: convert.hex_to_bytes(k[2:]))
             for key in payload["storageKeys"]
         ],
     )
Beispiel #2
0
 def from_json(cls, payload: Dict[str, Any]) -> "JsonRpcResponse":
     if not (rpc_constants.JSON_RPC_RESULT not in payload) ^ (
             rpc_constants.JSON_RPC_ERROR not in payload):
         raise ValueError(
             "Cannot instantiate a message with neither (or both) a result and error."
         )
     return cls(
         payload.get(rpc_constants.JSON_RPC_REQUEST_ID, None),
         payload.get(rpc_constants.JSON_RPC_RESULT, None),
         utils.optional_map(payload.get(rpc_constants.JSON_RPC_ERROR, None),
                            RpcError.from_json))
Beispiel #3
0
 def from_json(cls, payload: Dict[str, Any]) -> "Transaction":
     return LegacyTransaction(
         int(payload["nonce"], 16),
         int(payload["gasPrice"], 16),
         int(payload["gas"], 16),
         utils.or_else(
             utils.optional_map(payload["to"],
                                lambda to: convert.hex_to_bytes(to[2:])),
             bytes()),
         int(payload["value"], 16),
         convert.hex_to_bytes(payload["input"][2:]),
         int(payload["v"], 16),
         int(payload["r"], 16),
         int(payload["s"], 16),
     )
Beispiel #4
0
 def from_json(cls, payload: Dict[str, Any]) -> "Transaction":
     return AccessListTransaction(
         int(payload["chainId"], 16),
         int(payload["nonce"], 16),
         int(payload["gasPrice"], 16),
         int(payload["gas"], 16),
         utils.or_else(
             utils.optional_map(payload["to"],
                                lambda to: convert.hex_to_bytes(to[2:])),
             bytes()),
         int(payload["value"], 16),
         convert.hex_to_bytes(payload["input"][2:]),
         [
             AccessedAddress.from_json(accessed_address)
             for accessed_address in payload["accessList"]
         ],
         int(payload["v"], 16),
         int(payload["r"], 16),
         int(payload["s"], 16),
     )