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

This commit is contained in:
Dani Mehrjerdi 2024-04-25 14:37:21 +04:00 committed by GitHub
parent 93a71f2eef
commit 2014d1e205
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 26 additions and 17 deletions

View File

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

View File

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

View File

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

View File

@ -90,6 +90,10 @@ export interface components {
/** @enum {string} */ /** @enum {string} */
type: "pending"; type: "pending";
} }
| {
/** @enum {string} */
type: "simulation_failed";
}
| { | {
/** /**
* Format: int32 * Format: int32
@ -188,7 +192,7 @@ export interface components {
/** @example 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12 */ /** @example 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12 */
signature: string; 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 * @example 1000000000000000000
*/ */
valid_until: string; valid_until: string;

View File

@ -105,13 +105,14 @@ class BidStatus(Enum):
SUBMITTED = "submitted" SUBMITTED = "submitted"
LOST = "lost" LOST = "lost"
PENDING = "pending" PENDING = "pending"
SIMULATION_FAILED = "simulation_failed"
class BidStatusUpdate(BaseModel): class BidStatusUpdate(BaseModel):
""" """
Attributes: Attributes:
id: The ID of the bid. 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. 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. 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") @model_validator(mode="after")
def check_result(self): 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" assert self.result is None, "result must be None"
else: else:
assert self.result is not None, "result must be a valid 32-byte hash" assert self.result is not None, "result must be a valid 32-byte hash"

View File

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

View File

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

2
package-lock.json generated
View File

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