@reflectmoney/oracle.ts 2.2.2 → 3.0.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 +17 -0
- package/dist/index.js +25 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,14 @@ export interface Oracle<T> {
|
|
|
9
9
|
slot: bigint;
|
|
10
10
|
payload: T;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Price data payload with precision information
|
|
14
|
+
* Matches the Rust PriceData struct
|
|
15
|
+
*/
|
|
16
|
+
export interface PriceData {
|
|
17
|
+
price: bigint;
|
|
18
|
+
precision: number;
|
|
19
|
+
}
|
|
12
20
|
/**
|
|
13
21
|
* Serializer interface for custom payload types
|
|
14
22
|
*/
|
|
@@ -34,6 +42,15 @@ export declare function createPricePayload(price: bigint): Buffer;
|
|
|
34
42
|
* Helper function to read a price value from a [u8; 8] payload
|
|
35
43
|
*/
|
|
36
44
|
export declare function readPriceFromPayload(payload: Buffer): bigint;
|
|
45
|
+
/**
|
|
46
|
+
* Built-in serializer for PriceData payloads
|
|
47
|
+
* Structure: 8 bytes for price, 1 byte for precision (total 9 bytes)
|
|
48
|
+
*/
|
|
49
|
+
export declare class PriceDataSerializer implements PayloadSerializer<PriceData> {
|
|
50
|
+
serialize(payload: PriceData): Buffer;
|
|
51
|
+
deserialize(buffer: Buffer): PriceData;
|
|
52
|
+
size(): number;
|
|
53
|
+
}
|
|
37
54
|
/**
|
|
38
55
|
* Transaction builder for Doppler oracle updates
|
|
39
56
|
*/
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Doppler = exports.TransactionBuilder = exports.U8Array8Serializer = exports.ADMIN_PUBKEY = exports.DOPPLER_PROGRAM_ID = void 0;
|
|
12
|
+
exports.Doppler = exports.TransactionBuilder = exports.PriceDataSerializer = exports.U8Array8Serializer = exports.ADMIN_PUBKEY = exports.DOPPLER_PROGRAM_ID = void 0;
|
|
13
13
|
exports.createPricePayload = createPricePayload;
|
|
14
14
|
exports.readPriceFromPayload = readPriceFromPayload;
|
|
15
15
|
const web3_js_1 = require("@solana/web3.js");
|
|
@@ -69,6 +69,30 @@ function readPriceFromPayload(payload) {
|
|
|
69
69
|
}
|
|
70
70
|
return payload.readBigUInt64LE(0);
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Built-in serializer for PriceData payloads
|
|
74
|
+
* Structure: 8 bytes for price, 1 byte for precision (total 9 bytes)
|
|
75
|
+
*/
|
|
76
|
+
class PriceDataSerializer {
|
|
77
|
+
serialize(payload) {
|
|
78
|
+
const buf = buffer_1.Buffer.alloc(9);
|
|
79
|
+
buf.writeBigUInt64LE(payload.price, 0);
|
|
80
|
+
buf.writeUInt8(payload.precision, 8);
|
|
81
|
+
return buf;
|
|
82
|
+
}
|
|
83
|
+
deserialize(buffer) {
|
|
84
|
+
if (buffer.length < 9) {
|
|
85
|
+
throw new Error('Buffer must be at least 9 bytes');
|
|
86
|
+
}
|
|
87
|
+
const price = buffer.readBigUInt64LE(0);
|
|
88
|
+
const precision = buffer.readUInt8(8);
|
|
89
|
+
return { price, precision };
|
|
90
|
+
}
|
|
91
|
+
size() {
|
|
92
|
+
return 9;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.PriceDataSerializer = PriceDataSerializer;
|
|
72
96
|
/**
|
|
73
97
|
* Transaction builder for Doppler oracle updates
|
|
74
98
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/index.ts"],"version":"5.9.3"}
|