Skip to content

Commit

Permalink
fix: camel case sdk and better schema (#244)
Browse files Browse the repository at this point in the history
* fix: use camel case in types

* Better types and schemas
  • Loading branch information
m30m authored Nov 18, 2024
1 parent 12e50e6 commit d24f635
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
3 changes: 3 additions & 0 deletions auction-server/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1680,9 +1680,12 @@ impl Store {
#[serde_as]
#[derive(Serialize, Clone, ToSchema, ToResponse)]
pub struct SvmChainUpdate {
#[schema(example = "solana", value_type = String)]
pub chain_id: ChainId,
#[serde_as(as = "DisplayFromStr")]
#[schema(example = "SLxp9LxX1eE9Z5v99Y92DaYEwyukFgMUF6zRerCF12j", value_type = String)]
pub blockhash: Hash,
/// The prioritization fee that the server suggests to use for the next transaction
#[schema(example = "1000", value_type = u64)]
pub latest_prioritization_fee: MicroLamports,
}
4 changes: 2 additions & 2 deletions sdk/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/express-relay-js",
"version": "0.14.1",
"version": "0.14.2",
"description": "Utilities for interacting with the express relay protocol",
"homepage": "https://github.com/pyth-network/per/tree/main/sdk/js",
"author": "Douro Labs",
Expand Down
4 changes: 2 additions & 2 deletions sdk/js/src/examples/simpleSearcherLimo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class SimpleSearcherLimo {
const ixsTakeOrder = await this.generateTakeOrderIxs(limoClient, order);
const feeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
microLamports:
this.latestChainUpdate[this.chainId].latest_prioritization_fee,
this.latestChainUpdate[this.chainId].latestPrioritizationFee,
});
const txRaw = new anchor.web3.Transaction().add(
feeInstruction,
Expand Down Expand Up @@ -236,7 +236,7 @@ export class SimpleSearcherLimo {
}

async svmChainUpdateHandler(update: SvmChainUpdate) {
this.latestChainUpdate[update.chain_id] = update;
this.latestChainUpdate[update.chainId] = update;
}

// NOTE: Developers are responsible for implementing custom removal logic specific to their use case.
Expand Down
8 changes: 7 additions & 1 deletion sdk/js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ export class Client {
}
} else if ("type" in message && message.type === "svm_chain_update") {
if (typeof this.websocketSvmChainUpdateCallback === "function") {
await this.websocketSvmChainUpdateCallback(message.update);
await this.websocketSvmChainUpdateCallback({
chainId: message.update.chain_id,
blockhash: message.update.blockhash,
latestPrioritizationFee: BigInt(
message.update.latest_prioritization_fee
),
});
}
} else if ("type" in message && message.type === "remove_opportunities") {
if (typeof this.websocketRemoveOpportunitiesCallback === "function") {
Expand Down
13 changes: 10 additions & 3 deletions sdk/js/src/serverTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,16 @@ export interface components {
items: components["schemas"]["SimulatedBid"][];
};
SvmChainUpdate: {
blockhash: components["schemas"]["Hash"];
chain_id: components["schemas"]["ChainId"];
latest_prioritization_fee: components["schemas"]["MicroLamports"];
/** @example SLxp9LxX1eE9Z5v99Y92DaYEwyukFgMUF6zRerCF12j */
blockhash: string;
/** @example solana */
chain_id: string;
/**
* Format: int64
* @description The prioritization fee that the server suggests to use for the next transaction
* @example 1000
*/
latest_prioritization_fee: number;
};
TokenAmountEvm: {
/**
Expand Down
6 changes: 5 additions & 1 deletion sdk/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ export type SvmConstantsConfig = {
expressRelayProgram: PublicKey;
};

export type SvmChainUpdate = components["schemas"]["SvmChainUpdate"];
export type SvmChainUpdate = {
chainId: ChainId;
blockhash: string;
latestPrioritizationFee: bigint;
};

export type OpportunityDeleteSvm = {
chainId: ChainId;
Expand Down

0 comments on commit d24f635

Please sign in to comment.