Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
m30m committed Oct 8, 2024
1 parent 51f65ef commit 4541f94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
18 changes: 8 additions & 10 deletions express_relay/sdk/js/src/examples/simpleSearcherLimo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ class SimpleSearcherLimo {
order.state.globalConfig
);
const bidAmount = new anchor.BN(argv.bid);
if (!this.expressRelayConfig) {
this.expressRelayConfig = await this.client.getExpressRelaySvmConfig(
this.chainId,
this.connectionSvm
);
}

const bid = await this.client.constructSvmBid(
txRaw,
Expand All @@ -120,8 +126,8 @@ class SimpleSearcherLimo {
bidAmount,
new anchor.BN(Math.round(Date.now() / 1000 + DAY_IN_SECONDS)),
this.chainId,
this.expressRelayConfig!.relayerSigner,
this.expressRelayConfig!.feeReceiverRelayer
this.expressRelayConfig.relayerSigner,
this.expressRelayConfig.feeReceiverRelayer
);

bid.transaction.recentBlockhash = opportunity.blockHash;
Expand All @@ -145,15 +151,7 @@ class SimpleSearcherLimo {
}
}

async fetchConfig() {
this.expressRelayConfig = await this.client.getExpressRelaySvmConfig(
this.chainId,
this.connectionSvm
);
}

async start() {
await this.fetchConfig();
try {
await this.client.subscribeChains([argv.chainId]);
console.log(
Expand Down
4 changes: 2 additions & 2 deletions express_relay/sdk/js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ export class Client {
}

private toServerBid(bid: Bid): components["schemas"]["Bid"] {
if (bid.env == "evm") {
if (bid.env === "evm") {
return {
amount: bid.amount.toString(),
target_calldata: bid.targetCalldata,
Expand All @@ -729,7 +729,7 @@ export class Client {
private convertOpportunity(
opportunity: components["schemas"]["Opportunity"]
): Opportunity | undefined {
if (opportunity.version != "v1") {
if (opportunity.version !== "v1") {
console.warn(
`Can not handle opportunity version: ${opportunity.version}. Please upgrade your client.`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
BidSvm,
Opportunity,
OpportunityEvm,
OpportunitySvm,
)
from express_relay.svm.generated.express_relay.accounts import ExpressRelayMetadata
from express_relay.svm.generated.express_relay.program_id import (
Expand Down Expand Up @@ -71,6 +72,9 @@ async def opportunity_callback(self, opp: Opportunity):
opp: An object representing a single opportunity.
"""

if isinstance(opp, OpportunityEvm):
raise ValueError("Opportunity is not an SVM opportunity")

bid = await self.assess_opportunity(opp)

if bid:
Expand Down Expand Up @@ -101,10 +105,7 @@ async def bid_status_callback(self, bid_status_update: BidStatusUpdate):
result_details = f", transaction {result}"
logger.info(f"Bid status for bid {id}: {bid_status.value}{result_details}")

async def assess_opportunity(self, opp: Opportunity) -> BidSvm:
if isinstance(opp, OpportunityEvm):
raise ValueError("Opportunity is not an SVM opportunity")

async def assess_opportunity(self, opp: OpportunitySvm) -> BidSvm:
order: OrderStateAndAddress = {"address": opp.order_address, "state": opp.order}
input_mint_decimals = await self.limo_client.get_mint_decimals(
order["state"].input_mint
Expand Down

0 comments on commit 4541f94

Please sign in to comment.