New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pythnetwork/express-relay-js

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pythnetwork/express-relay-js - npm Package Compare versions

Comparing version 0.20.0 to 0.21.0

1

lib/examples/simpleSearcherSvm.d.ts

@@ -20,2 +20,3 @@ import yargs from "yargs";

protected readonly bid: anchor.BN;
protected bidChainId: Record<string, string>;
constructor(endpointExpressRelay: string, chainId: string, searcher: Keypair, endpointSvm: string, bid: number, apiKey?: string | undefined);

@@ -22,0 +23,0 @@ websocketCloseHandler(): Promise<void>;

@@ -55,2 +55,3 @@ "use strict";

bid;
bidChainId = {};
constructor(endpointExpressRelay, chainId, searcher, endpointSvm, bid, apiKey) {

@@ -74,4 +75,16 @@ this.endpointExpressRelay = endpointExpressRelay;

async bidStatusHandler(bidStatus) {
console.log("hiiiii daniiiiii");
console.log(`Bid status for bid ${bidStatus.id}: ${JSON.stringify(bidStatus)}`);
// It's possible to cancel bids with status awaiting_signature
// Doing it here randomly for demonstration purposes
if (bidStatus.type === "awaiting_signature") {
if (this.bidChainId[bidStatus.id] && Math.random() < 1.0 / 3.0) {
try {
await this.client.cancelBid(bidStatus.id, this.bidChainId[bidStatus.id]);
console.log(`Cancelled bid ${bidStatus.id}`);
}
catch (error) {
console.error(`Failed to cancel bid ${bidStatus.id}: ${error}`);
}
}
}
}

@@ -194,2 +207,3 @@ async getMintDecimalsCached(mint) {

const bidId = await this.client.submitBid(bid);
this.bidChainId[bidId] = opportunity.chainId;
console.log(`Successful bid. Opportunity id ${opportunity.opportunityId} Bid id ${bidId}`);

@@ -196,0 +210,0 @@ }

@@ -5,5 +5,6 @@ import type { components } from "./serverTypes";

import WebSocket from "isomorphic-ws";
import { Bid, BidId, BidParams, BidsResponse, BidStatusUpdate, ExpressRelaySvmConfig, Opportunity, OpportunityBid, OpportunityEvm, OpportunityCreate, TokenAmount, SvmChainUpdate, OpportunityDelete, QuoteRequest, QuoteResponse, BidSvmOnChain, BidSvmSwap, OpportunitySvmSwap } from "./types";
import { Bid, BidId, BidParams, BidsResponse, BidStatusUpdate, ExpressRelaySvmConfig, Opportunity, OpportunityBid, OpportunityEvm, OpportunityCreate, TokenAmount, SvmChainUpdate, OpportunityDelete, QuoteRequest, QuoteResponse, BidSvmOnChain, BidSvmSwap, OpportunitySvmSwap, SubmitQuote } from "./types";
import { Connection, PublicKey, Transaction, TransactionInstruction } from "@solana/web3.js";
import * as anchor from "@coral-xyz/anchor";
import { VersionedTransaction } from "@solana/web3.js";
export * from "./types";

@@ -65,2 +66,9 @@ export * from "./const";

unsubscribeChains(chains: string[]): Promise<void>;
/**
* Cancels a bid
*
* Bids can only be cancelled if they are in awaiting_signature state
* @param chains
*/
cancelBid(bid_id: string, chain_id: string): Promise<void>;
requestViaWebsocket(msg: components["schemas"]["ClientMessage"]): Promise<components["schemas"]["APIResponse"] | null>;

@@ -92,2 +100,8 @@ /**

/**
* Posts a submit quote request to the server
* @param submitQuote The quote data to be submitted on-chain
* @returns The fully signed transaction that was submitted on-chain
*/
submitQuote(submitQuote: SubmitQuote): Promise<VersionedTransaction>;
/**
* Submits a raw bid for a permission key

@@ -94,0 +108,0 @@ * @param bid

@@ -235,2 +235,19 @@ "use strict";

}
/**
* Cancels a bid
*
* Bids can only be cancelled if they are in awaiting_signature state
* @param chains
*/
async cancelBid(bid_id, chain_id) {
await this.requestViaWebsocket({
method: "cancel_bid",
params: {
data: {
bid_id,
chain_id,
},
},
});
}
async requestViaWebsocket(msg) {

@@ -415,2 +432,26 @@ const msg_with_id = {

/**
* Posts a submit quote request to the server
* @param submitQuote The quote data to be submitted on-chain
* @returns The fully signed transaction that was submitted on-chain
*/
async submitQuote(submitQuote) {
const client = (0, openapi_fetch_1.default)(this.clientOptions);
const body = {
reference_id: submitQuote.referenceId,
user_signature: submitQuote.userSignature,
};
const response = await client.POST("/v1/{chain_id}/quotes/submit", {
params: {
path: {
chain_id: submitQuote.chainId,
},
},
body,
});
if (response.error) {
throw ClientError.newHttpError(JSON.stringify(response.error), response.response.status);
}
return web3_js_2.VersionedTransaction.deserialize(new Uint8Array(bytes_1.base64.decode(response.data.transaction)));
}
/**
* Submits a raw bid for a permission key

@@ -595,2 +636,3 @@ * @param bid

transaction: web3_js_2.VersionedTransaction.deserialize(new Uint8Array(bytes_1.base64.decode(quoteResponse.transaction))),
referenceId: quoteResponse.reference_id,
};

@@ -597,0 +639,0 @@ }

@@ -363,3 +363,9 @@ import { Address, Hex } from "viem";

transaction: VersionedTransaction;
referenceId: string;
};
export type SubmitQuote = {
chainId: ChainId;
referenceId: components["schemas"]["SubmitQuote"]["reference_id"];
userSignature: components["schemas"]["SubmitQuote"]["user_signature"];
};
//# sourceMappingURL=types.d.ts.map

6

package.json
{
"name": "@pythnetwork/express-relay-js",
"version": "0.20.0",
"version": "0.21.0",
"description": "Utilities for interacting with the express relay protocol",

@@ -34,3 +34,3 @@ "homepage": "https://github.com/pyth-network/per/tree/main/sdk/js",

"openapi-client-axios": "^7.5.5",
"openapi-fetch": "^0.8.2",
"openapi-fetch": "^0.13.4",
"viem": "2.16.2",

@@ -44,3 +44,3 @@ "ws": "^8.17.1"

"jest": "27.5.1",
"openapi-typescript": "6.5.5",
"openapi-typescript": "7.6.1",
"prettier": "^2.8.8",

@@ -47,0 +47,0 @@ "typescript": "5.5.4",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc