@cowprotocol/sdk-trading-solana 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -64,6 +64,12 @@ declare function encodeOrderIntent(intent: SolanaOrderIntent): Uint8Array;
64
64
  */
65
65
  declare function hashOrderIntent(encoded: Uint8Array): Promise<Uint8Array>;
66
66
  declare function toHex(bytes: Uint8Array): string;
67
+ /**
68
+ * Formats a uid as an order id in the same "0x"-prefixed form the order-book API returns in
69
+ * `EnrichedOrder.uid` (matching EVM order uids). Code that looks an order up by the API's uid
70
+ * (reducer batch actions, notifications, etc.) needs this to match whatever id was stored locally.
71
+ */
72
+ declare function toOrderId(uid: Uint8Array): string;
67
73
 
68
74
  interface SolanaQuoteParameters {
69
75
  ownerAddress: PublicKeyInitData;
@@ -198,4 +204,4 @@ declare class SolanaTradingSdk {
198
204
  getQuote(params: SolanaQuoteParameters): Promise<QuoteAndPost>;
199
205
  }
200
206
 
201
- export { type CreateOrderInstructionParams, ENCODED_ORDER_INTENT_SIZE, JupiterAPI, type JupiterOrderRequest, type JupiterOrderResponse, ORDER_SEED, type SolanaOrderIntent, type SolanaQuote, type SolanaQuoteParameters, type SolanaSignAndSend, SolanaTradingSdk, type SolanaTradingSdkOptions, buildCreateOrderInstruction, encodeOrderIntent, findOrderPda, findSettlementStatePda, getSettlementSeed, getSolanaDelegateAuthority, getSolanaQuote, getSolanaSettlementProgramId, hashOrderIntent, postSolanaSwapOrderFromQuote, toHex };
207
+ export { type CreateOrderInstructionParams, ENCODED_ORDER_INTENT_SIZE, JupiterAPI, type JupiterOrderRequest, type JupiterOrderResponse, ORDER_SEED, type SolanaOrderIntent, type SolanaQuote, type SolanaQuoteParameters, type SolanaSignAndSend, SolanaTradingSdk, type SolanaTradingSdkOptions, buildCreateOrderInstruction, encodeOrderIntent, findOrderPda, findSettlementStatePda, getSettlementSeed, getSolanaDelegateAuthority, getSolanaQuote, getSolanaSettlementProgramId, hashOrderIntent, postSolanaSwapOrderFromQuote, toHex, toOrderId };
package/dist/index.d.ts CHANGED
@@ -64,6 +64,12 @@ declare function encodeOrderIntent(intent: SolanaOrderIntent): Uint8Array;
64
64
  */
65
65
  declare function hashOrderIntent(encoded: Uint8Array): Promise<Uint8Array>;
66
66
  declare function toHex(bytes: Uint8Array): string;
67
+ /**
68
+ * Formats a uid as an order id in the same "0x"-prefixed form the order-book API returns in
69
+ * `EnrichedOrder.uid` (matching EVM order uids). Code that looks an order up by the API's uid
70
+ * (reducer batch actions, notifications, etc.) needs this to match whatever id was stored locally.
71
+ */
72
+ declare function toOrderId(uid: Uint8Array): string;
67
73
 
68
74
  interface SolanaQuoteParameters {
69
75
  ownerAddress: PublicKeyInitData;
@@ -198,4 +204,4 @@ declare class SolanaTradingSdk {
198
204
  getQuote(params: SolanaQuoteParameters): Promise<QuoteAndPost>;
199
205
  }
200
206
 
201
- export { type CreateOrderInstructionParams, ENCODED_ORDER_INTENT_SIZE, JupiterAPI, type JupiterOrderRequest, type JupiterOrderResponse, ORDER_SEED, type SolanaOrderIntent, type SolanaQuote, type SolanaQuoteParameters, type SolanaSignAndSend, SolanaTradingSdk, type SolanaTradingSdkOptions, buildCreateOrderInstruction, encodeOrderIntent, findOrderPda, findSettlementStatePda, getSettlementSeed, getSolanaDelegateAuthority, getSolanaQuote, getSolanaSettlementProgramId, hashOrderIntent, postSolanaSwapOrderFromQuote, toHex };
207
+ export { type CreateOrderInstructionParams, ENCODED_ORDER_INTENT_SIZE, JupiterAPI, type JupiterOrderRequest, type JupiterOrderResponse, ORDER_SEED, type SolanaOrderIntent, type SolanaQuote, type SolanaQuoteParameters, type SolanaSignAndSend, SolanaTradingSdk, type SolanaTradingSdkOptions, buildCreateOrderInstruction, encodeOrderIntent, findOrderPda, findSettlementStatePda, getSettlementSeed, getSolanaDelegateAuthority, getSolanaQuote, getSolanaSettlementProgramId, hashOrderIntent, postSolanaSwapOrderFromQuote, toHex, toOrderId };
package/dist/index.js CHANGED
@@ -34,7 +34,8 @@ __export(src_exports, {
34
34
  getSolanaSettlementProgramId: () => getSolanaSettlementProgramId,
35
35
  hashOrderIntent: () => hashOrderIntent,
36
36
  postSolanaSwapOrderFromQuote: () => postSolanaSwapOrderFromQuote,
37
- toHex: () => toHex
37
+ toHex: () => toHex,
38
+ toOrderId: () => toOrderId
38
39
  });
39
40
  module.exports = __toCommonJS(src_exports);
40
41
 
@@ -91,6 +92,9 @@ async function hashOrderIntent(encoded) {
91
92
  function toHex(bytes) {
92
93
  return Array.from(bytes).map((byte) => byte.toString(16).padStart(2, "0")).join("");
93
94
  }
95
+ function toOrderId(uid) {
96
+ return `0x${toHex(uid)}`;
97
+ }
94
98
 
95
99
  // src/orderPda.ts
96
100
  var import_web3 = require("@solana/web3.js");
@@ -358,7 +362,7 @@ async function postSolanaSwapOrderFromQuote({ quoteResults, solanaQuote }, signA
358
362
  await signingStepManager?.afterOrderSign?.();
359
363
  const orderToSign = quoteResults.orderToSign;
360
364
  return {
361
- orderId: toHex(uid),
365
+ orderId: toOrderId(uid),
362
366
  txHash: signature,
363
367
  signature,
364
368
  signingScheme: import_sdk_order_book3.SigningScheme.PRESIGN,
@@ -395,5 +399,6 @@ var SolanaTradingSdk = class {
395
399
  getSolanaSettlementProgramId,
396
400
  hashOrderIntent,
397
401
  postSolanaSwapOrderFromQuote,
398
- toHex
402
+ toHex,
403
+ toOrderId
399
404
  });
package/dist/index.mjs CHANGED
@@ -51,6 +51,9 @@ async function hashOrderIntent(encoded) {
51
51
  function toHex(bytes) {
52
52
  return Array.from(bytes).map((byte) => byte.toString(16).padStart(2, "0")).join("");
53
53
  }
54
+ function toOrderId(uid) {
55
+ return `0x${toHex(uid)}`;
56
+ }
54
57
 
55
58
  // src/orderPda.ts
56
59
  import { PublicKey } from "@solana/web3.js";
@@ -321,7 +324,7 @@ async function postSolanaSwapOrderFromQuote({ quoteResults, solanaQuote }, signA
321
324
  await signingStepManager?.afterOrderSign?.();
322
325
  const orderToSign = quoteResults.orderToSign;
323
326
  return {
324
- orderId: toHex(uid),
327
+ orderId: toOrderId(uid),
325
328
  txHash: signature,
326
329
  signature,
327
330
  signingScheme: SigningScheme.PRESIGN,
@@ -357,5 +360,6 @@ export {
357
360
  getSolanaSettlementProgramId,
358
361
  hashOrderIntent,
359
362
  postSolanaSwapOrderFromQuote,
360
- toHex
363
+ toHex,
364
+ toOrderId
361
365
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-trading-solana",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "CowProtocol Solana trading: Jupiter-sourced quotes and on-chain CreateOrder posting against the Solana settlement program",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,9 +39,9 @@
39
39
  "dependencies": {
40
40
  "@solana/spl-token": "0.4.14",
41
41
  "@solana/web3.js": "1.98.4",
42
+ "@cowprotocol/sdk-trading": "2.4.1",
42
43
  "@cowprotocol/sdk-config": "2.6.0",
43
- "@cowprotocol/sdk-order-book": "4.0.4",
44
- "@cowprotocol/sdk-trading": "2.4.1"
44
+ "@cowprotocol/sdk-order-book": "4.0.4"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsup src/index.ts --format esm,cjs --dts",