Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pythnetwork/express-relay-evm-js

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.2.1 to 0.4.0

1

lib/index.d.ts

@@ -34,2 +34,3 @@ import type { components } from "./serverTypes";

private connectWebsocket;
private convertEIP712Domain;
/**

@@ -36,0 +37,0 @@ * Converts an opportunity from the server to the client format

92

lib/index.js

@@ -105,2 +105,10 @@ "use strict";

}
convertEIP712Domain(eip712Domain) {
return {
name: eip712Domain.name,
version: eip712Domain.version,
verifyingContract: checkAddress(eip712Domain.verifying_contract),
chainId: BigInt(eip712Domain.chain_id),
};
}
/**

@@ -125,2 +133,3 @@ * Converts an opportunity from the server to the client format

buyTokens: opportunity.buy_tokens.map(checkTokenQty),
eip712Domain: this.convertEIP712Domain(opportunity.eip_712_domain),
};

@@ -251,48 +260,43 @@ }

async signOpportunityBid(opportunity, bidParams, privateKey) {
const types = {
SignedParams: [
{ name: "executionParams", type: "ExecutionParams" },
{ name: "signer", type: "address" },
{ name: "deadline", type: "uint256" },
],
ExecutionParams: [
{ name: "sellTokens", type: "TokenAmount[]" },
{ name: "buyTokens", type: "TokenAmount[]" },
{ name: "targetContract", type: "address" },
{ name: "targetCalldata", type: "bytes" },
{ name: "targetCallValue", type: "uint256" },
{ name: "bidAmount", type: "uint256" },
],
TokenAmount: [
{ name: "token", type: "address" },
{ name: "amount", type: "uint256" },
],
};
const account = (0, accounts_1.privateKeyToAccount)(privateKey);
const convertTokenQty = ({ token, amount }) => [
token,
amount,
];
const payload = (0, viem_1.encodeAbiParameters)([
{
name: "repayTokens",
type: "tuple[]",
components: [
{
type: "address",
},
{
type: "uint256",
},
],
const signature = await (0, accounts_1.signTypedData)({
privateKey,
domain: {
...opportunity.eip712Domain,
chainId: Number(opportunity.eip712Domain.chainId),
},
{
name: "receiptTokens",
type: "tuple[]",
components: [
{
type: "address",
},
{
type: "uint256",
},
],
types,
primaryType: "SignedParams",
message: {
executionParams: {
sellTokens: opportunity.sellTokens,
buyTokens: opportunity.buyTokens,
targetContract: opportunity.targetContract,
targetCalldata: opportunity.targetCalldata,
targetCallValue: opportunity.targetCallValue,
bidAmount: bidParams.amount,
},
signer: account.address,
deadline: bidParams.validUntil,
},
{ name: "contract", type: "address" },
{ name: "calldata", type: "bytes" },
{ name: "value", type: "uint256" },
{ name: "bid", type: "uint256" },
{ name: "validUntil", type: "uint256" },
], [
opportunity.sellTokens.map(convertTokenQty),
opportunity.buyTokens.map(convertTokenQty),
opportunity.targetContract,
opportunity.targetCalldata,
opportunity.targetCallValue,
bidParams.amount,
bidParams.validUntil,
]);
const msgHash = (0, viem_1.keccak256)(payload);
const hash = (0, accounts_1.signatureToHex)(await (0, accounts_1.sign)({ hash: msgHash, privateKey }));
});
return {

@@ -302,3 +306,3 @@ permissionKey: opportunity.permissionKey,

executor: account.address,
signature: hash,
signature,
opportunityId: opportunity.opportunityId,

@@ -305,0 +309,0 @@ };

@@ -26,2 +26,23 @@ import { Address, Hex } from "viem";

/**
* Represents the configuration for signing an opportunity
*/
export type EIP712Domain = {
/**
* The network chain id for the EIP712 domain.
*/
chainId: bigint;
/**
* The verifying contract address for the EIP712 domain.
*/
verifyingContract: Address;
/**
* The name parameter for the EIP712 domain.
*/
name: string;
/**
* The version parameter for the EIP712 domain.
*/
version: string;
};
/**
* Represents a valid opportunity ready to be executed

@@ -62,2 +83,6 @@ */

buyTokens: TokenAmount[];
/**
* The data required to sign the opportunity
*/
eip712Domain: EIP712Domain;
};

@@ -67,3 +92,3 @@ /**

*/
export type OpportunityParams = Omit<Opportunity, "opportunityId">;
export type OpportunityParams = Omit<Opportunity, "opportunityId" | "eip712Domain">;
/**

@@ -70,0 +95,0 @@ * Represents a bid for an opportunity

{
"name": "@pythnetwork/express-relay-evm-js",
"version": "0.2.1",
"version": "0.4.0",
"description": "Utilities for interacting with the express relay protocol",

@@ -57,3 +57,3 @@ "homepage": "https://github.com/pyth-network/pyth-crosschain/tree/main/express_relay/sdk/js",

"license": "Apache-2.0",
"gitHead": "70c2c8ec4b5092729791f642493072565d953439"
"gitHead": "508de7583953af4299143affea71f8dd4633cd32"
}

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