From 2014d1e2058ac9f347c6c081a5bf24ca34d7693a Mon Sep 17 00:00:00 2001 From: Dani Mehrjerdi Date: Thu, 25 Apr 2024 14:37:21 +0400 Subject: [PATCH] feat(express-relay): Add simulation_failed to bid status (#1503) --- express_relay/sdk/js/package-lock.json | 2 +- express_relay/sdk/js/package.json | 2 +- .../sdk/js/src/examples/simpleSearcher.ts | 5 ++++- express_relay/sdk/js/src/serverTypes.d.ts | 6 +++++- .../python/express_relay/express_relay_types.py | 8 ++++++-- .../searcher/examples/simple_searcher.py | 16 +++++++--------- express_relay/sdk/python/pyproject.toml | 2 +- package-lock.json | 2 +- 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/express_relay/sdk/js/package-lock.json b/express_relay/sdk/js/package-lock.json index b723770b..1b908071 100644 --- a/express_relay/sdk/js/package-lock.json +++ b/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": { diff --git a/express_relay/sdk/js/package.json b/express_relay/sdk/js/package.json index 5f7759ed..7d74f054 100644 --- a/express_relay/sdk/js/package.json +++ b/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", diff --git a/express_relay/sdk/js/src/examples/simpleSearcher.ts b/express_relay/sdk/js/src/examples/simpleSearcher.ts index f9529b04..53ac1897 100644 --- a/express_relay/sdk/js/src/examples/simpleSearcher.ts +++ b/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}` ); } diff --git a/express_relay/sdk/js/src/serverTypes.d.ts b/express_relay/sdk/js/src/serverTypes.d.ts index c2f91018..f841bad1 100644 --- a/express_relay/sdk/js/src/serverTypes.d.ts +++ b/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; diff --git a/express_relay/sdk/python/express_relay/express_relay_types.py b/express_relay/sdk/python/express_relay/express_relay_types.py index 9ae24471..aef41dd5 100644 --- a/express_relay/sdk/python/express_relay/express_relay_types.py +++ b/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" diff --git a/express_relay/sdk/python/express_relay/searcher/examples/simple_searcher.py b/express_relay/sdk/python/express_relay/searcher/examples/simple_searcher.py index 3af63e64..b4dcabab 100644 --- a/express_relay/sdk/python/express_relay/searcher/examples/simple_searcher.py +++ b/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(): diff --git a/express_relay/sdk/python/pyproject.toml b/express_relay/sdk/python/pyproject.toml index 9c2ce1fa..fbca64cb 100644 --- a/express_relay/sdk/python/pyproject.toml +++ b/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" diff --git a/package-lock.json b/package-lock.json index af7ffcc0..b48d1157 100644 --- a/package-lock.json +++ b/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",