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",
"version": "0.4.0",
"version": "0.4.1",
"lockfileVersion": 3,
"requires": true,
"packages": {

View File

@ -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",

View File

@ -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}`
);
}

View File

@ -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;

View File

@ -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"

View File

@ -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():

View File

@ -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"

2
package-lock.json generated
View File

@ -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",