@reflectmoney/oracle.ts 3.0.0 → 3.1.0

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.ts CHANGED
@@ -38,10 +38,18 @@ export declare class U8Array8Serializer implements PayloadSerializer<Buffer> {
38
38
  * Helper function to create a [u8; 8] payload from a bigint price value
39
39
  */
40
40
  export declare function createPricePayload(price: bigint): Buffer;
41
+ /**
42
+ * Helper function to create a PriceData payload buffer from price and precision
43
+ */
44
+ export declare function createPriceDataPayload(price: bigint, precision: number): Buffer;
41
45
  /**
42
46
  * Helper function to read a price value from a [u8; 8] payload
43
47
  */
44
48
  export declare function readPriceFromPayload(payload: Buffer): bigint;
49
+ /**
50
+ * Helper function to read PriceData from a buffer payload
51
+ */
52
+ export declare function readPriceDataFromPayload(payload: Buffer): PriceData;
45
53
  /**
46
54
  * Built-in serializer for PriceData payloads
47
55
  * Structure: 8 bytes for price, 1 byte for precision (total 9 bytes)
package/dist/index.js CHANGED
@@ -11,7 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Doppler = exports.TransactionBuilder = exports.PriceDataSerializer = exports.U8Array8Serializer = exports.ADMIN_PUBKEY = exports.DOPPLER_PROGRAM_ID = void 0;
13
13
  exports.createPricePayload = createPricePayload;
14
+ exports.createPriceDataPayload = createPriceDataPayload;
14
15
  exports.readPriceFromPayload = readPriceFromPayload;
16
+ exports.readPriceDataFromPayload = readPriceDataFromPayload;
15
17
  const web3_js_1 = require("@solana/web3.js");
16
18
  const buffer_1 = require("buffer");
17
19
  const compute_budget_1 = require("@solana-program/compute-budget");
@@ -60,6 +62,15 @@ function createPricePayload(price) {
60
62
  buf.writeBigUInt64LE(price);
61
63
  return buf;
62
64
  }
65
+ /**
66
+ * Helper function to create a PriceData payload buffer from price and precision
67
+ */
68
+ function createPriceDataPayload(price, precision) {
69
+ const buf = buffer_1.Buffer.alloc(9);
70
+ buf.writeBigUInt64LE(price, 0);
71
+ buf.writeUInt8(precision, 8);
72
+ return buf;
73
+ }
63
74
  /**
64
75
  * Helper function to read a price value from a [u8; 8] payload
65
76
  */
@@ -69,6 +80,17 @@ function readPriceFromPayload(payload) {
69
80
  }
70
81
  return payload.readBigUInt64LE(0);
71
82
  }
83
+ /**
84
+ * Helper function to read PriceData from a buffer payload
85
+ */
86
+ function readPriceDataFromPayload(payload) {
87
+ if (payload.length < 9) {
88
+ throw new Error('Payload must be at least 9 bytes');
89
+ }
90
+ const price = payload.readBigUInt64LE(0);
91
+ const precision = payload.readUInt8(8);
92
+ return { price, precision };
93
+ }
72
94
  /**
73
95
  * Built-in serializer for PriceData payloads
74
96
  * Structure: 8 bytes for price, 1 byte for precision (total 9 bytes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/oracle.ts",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "type": "commonjs",
5
5
  "author": "L0STE, stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {