Browse Source

feat(express-relay): Add simulation_failed to bid status (#1503)

Dani Mehrjerdi 1 year ago
parent
commit
2014d1e205

+ 1 - 1
express_relay/sdk/js/package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/express-relay-evm-js",
-  "version": "0.4.0",
+  "version": "0.4.1",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {

+ 1 - 1
express_relay/sdk/js/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/express-relay-evm-js",
-  "version": "0.4.0",
+  "version": "0.4.1",
   "description": "Utilities for interacting with the express relay protocol",
   "homepage": "https://github.com/pyth-network/pyth-crosschain/tree/main/express_relay/sdk/js",
   "author": "Douro Labs",

+ 4 - 1
express_relay/sdk/js/src/examples/simpleSearcher.ts

@@ -30,7 +30,10 @@ class SimpleSearcher {
       resultDetails = `, transaction ${bidStatus.result}`;
     }
     console.log(
-      `Bid status for bid ${bidStatus.id}: ${bidStatus.type}${resultDetails}`
+      `Bid status for bid ${bidStatus.id}: ${bidStatus.type.replaceAll(
+        "_",
+        " "
+      )}${resultDetails}`
     );
   }
 

+ 5 - 1
express_relay/sdk/js/src/serverTypes.d.ts

@@ -90,6 +90,10 @@ export interface components {
           /** @enum {string} */
           type: "pending";
         }
+      | {
+          /** @enum {string} */
+          type: "simulation_failed";
+        }
       | {
           /**
            * Format: int32
@@ -188,7 +192,7 @@ export interface components {
       /** @example 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12 */
       signature: string;
       /**
-       * @description How long the bid will be valid for.
+       * @description The latest unix timestamp in seconds until which the bid is valid
        * @example 1000000000000000000
        */
       valid_until: string;

+ 6 - 2
express_relay/sdk/python/express_relay/express_relay_types.py

@@ -105,13 +105,14 @@ class BidStatus(Enum):
     SUBMITTED = "submitted"
     LOST = "lost"
     PENDING = "pending"
+    SIMULATION_FAILED = "simulation_failed"
 
 
 class BidStatusUpdate(BaseModel):
     """
     Attributes:
         id: The ID of the bid.
-        bid_status: The status enum, either SUBMITTED, LOST, or PENDING.
+        bid_status: The current status of the bid.
         result: The result of the bid: a transaction hash if the status is SUBMITTED or LOST, else None.
         index: The index of the bid in the submitted transaction; None if the status is not SUBMITTED.
     """
@@ -123,7 +124,10 @@ class BidStatusUpdate(BaseModel):
 
     @model_validator(mode="after")
     def check_result(self):
-        if self.bid_status == BidStatus("pending"):
+        if self.bid_status in [
+            BidStatus("pending"),
+            BidStatus("simulation_failed"),
+        ]:
             assert self.result is None, "result must be None"
         else:
             assert self.result is not None, "result must be a valid 32-byte hash"

+ 7 - 9
express_relay/sdk/python/express_relay/searcher/examples/simple_searcher.py

@@ -76,18 +76,16 @@ class SimpleSearcher:
         bid_status = bid_status_update.bid_status
         result = bid_status_update.result
 
+        result_details = ""
         if bid_status == BidStatus("submitted"):
-            logger.info(
-                f"Bid {id} has been submitted in transaction {result} at index {bid_status_update.index} of the multicall"
+            result_details = (
+                f", transaction {result}, index {bid_status_update.index} of multicall"
             )
         elif bid_status == BidStatus("lost"):
-            logger.info(
-                f"Bid {id} was unsuccessful, not included in transaction {result}"
-            )
-        elif bid_status == BidStatus("pending"):
-            logger.info(f"Bid {id} is pending")
-        else:
-            logger.error(f"Unrecognized status {bid_status} for bid {id}")
+            result_details = f", transaction {result}"
+        logger.error(
+            f"Bid status for bid {id}: {bid_status.value.replace('_', ' ')}{result_details}"
+        )
 
 
 async def main():

+ 1 - 1
express_relay/sdk/python/pyproject.toml

@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "express-relay"
-version = "0.4.1"
+version = "0.4.2"
 description = "Utilities for searchers and protocols to interact with the Express Relay protocol."
 authors = ["dourolabs"]
 license = "Proprietary"

+ 1 - 1
package-lock.json

@@ -1751,7 +1751,7 @@
     },
     "express_relay/sdk/js": {
       "name": "@pythnetwork/express-relay-evm-js",
-      "version": "0.4.0",
+      "version": "0.4.1",
       "license": "Apache-2.0",
       "dependencies": {
         "isomorphic-ws": "^5.0.0",