@reflectmoney/oracle.ts 2.0.0 → 2.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
@@ -47,7 +47,7 @@ export declare class TransactionBuilder {
47
47
  /**
48
48
  * Add an oracle update instruction to the transaction
49
49
  */
50
- addOracleUpdate<T>(oraclePubkey: PublicKey, oracle: Oracle<T>, serializer: PayloadSerializer<T>): this;
50
+ addOracleUpdate<T>(oraclePubkey: PublicKey, payload: T, serializer: PayloadSerializer<T>): this;
51
51
  /**
52
52
  * Set the compute unit price in micro-lamports
53
53
  */
@@ -57,7 +57,6 @@ export declare class TransactionBuilder {
57
57
  */
58
58
  build(recentBlockhash: string): Transaction;
59
59
  private createUpdateInstruction;
60
- private serializeOracle;
61
60
  }
62
61
  /**
63
62
  * Main Doppler class for interacting with oracle accounts
@@ -81,17 +80,17 @@ export declare class Doppler {
81
80
  /**
82
81
  * Create an oracle account with a seed
83
82
  */
84
- createOracleAccount<T>(seed: string, serializer: PayloadSerializer<T>, initialOracle: Oracle<T>): Promise<PublicKey>;
83
+ createOracleAccount<T>(seed: string, serializer: PayloadSerializer<T>): Promise<PublicKey>;
85
84
  /**
86
85
  * Update a single oracle account
87
86
  */
88
- updateOracle<T>(oraclePubkey: PublicKey, oracle: Oracle<T>, serializer: PayloadSerializer<T>, unitPrice?: bigint): Promise<string>;
87
+ updateOracle<T>(oraclePubkey: PublicKey, payload: T, serializer: PayloadSerializer<T>, unitPrice?: bigint): Promise<string>;
89
88
  /**
90
89
  * Update multiple oracle accounts in a single transaction
91
90
  */
92
91
  updateMultipleOracles<T>(updates: Array<{
93
92
  oraclePubkey: PublicKey;
94
- oracle: Oracle<T>;
93
+ payload: T;
95
94
  serializer: PayloadSerializer<T>;
96
95
  }>, unitPrice?: bigint): Promise<string>;
97
96
  /**
package/dist/index.js CHANGED
@@ -85,8 +85,8 @@ class TransactionBuilder {
85
85
  /**
86
86
  * Add an oracle update instruction to the transaction
87
87
  */
88
- addOracleUpdate(oraclePubkey, oracle, serializer) {
89
- const instruction = this.createUpdateInstruction(oraclePubkey, oracle, serializer);
88
+ addOracleUpdate(oraclePubkey, payload, serializer) {
89
+ const instruction = this.createUpdateInstruction(oraclePubkey, payload, serializer);
90
90
  const payloadSize = serializer.size();
91
91
  const oracleSize = 8 + payloadSize; // slot + payload
92
92
  this.computeUnits +=
@@ -139,8 +139,8 @@ class TransactionBuilder {
139
139
  transaction.sign(this.admin);
140
140
  return transaction;
141
141
  }
142
- createUpdateInstruction(oraclePubkey, oracle, serializer) {
143
- const data = this.serializeOracle(oracle, serializer);
142
+ createUpdateInstruction(oraclePubkey, payload, serializer) {
143
+ const data = serializer.serialize(payload);
144
144
  return new web3_js_1.TransactionInstruction({
145
145
  programId: exports.DOPPLER_PROGRAM_ID,
146
146
  keys: [
@@ -163,12 +163,6 @@ class TransactionBuilder {
163
163
  data,
164
164
  });
165
165
  }
166
- serializeOracle(oracle, serializer) {
167
- const slotBuffer = buffer_1.Buffer.alloc(8);
168
- slotBuffer.writeBigUInt64LE(oracle.slot);
169
- const payloadBuffer = serializer.serialize(oracle.payload);
170
- return buffer_1.Buffer.concat([slotBuffer, payloadBuffer]);
171
- }
172
166
  }
173
167
  exports.TransactionBuilder = TransactionBuilder;
174
168
  /**
@@ -219,7 +213,7 @@ class Doppler {
219
213
  /**
220
214
  * Create an oracle account with a seed
221
215
  */
222
- createOracleAccount(seed, serializer, initialOracle) {
216
+ createOracleAccount(seed, serializer) {
223
217
  return __awaiter(this, void 0, void 0, function* () {
224
218
  const oracleSize = 8 + serializer.size();
225
219
  const lamports = yield this.connection.getMinimumBalanceForRentExemption(oracleSize);
@@ -247,10 +241,10 @@ class Doppler {
247
241
  /**
248
242
  * Update a single oracle account
249
243
  */
250
- updateOracle(oraclePubkey, oracle, serializer, unitPrice) {
244
+ updateOracle(oraclePubkey, payload, serializer, unitPrice) {
251
245
  return __awaiter(this, void 0, void 0, function* () {
252
246
  const recentBlockhash = yield this.connection.getLatestBlockhash();
253
- let builder = this.createTransactionBuilder().addOracleUpdate(oraclePubkey, oracle, serializer);
247
+ let builder = this.createTransactionBuilder().addOracleUpdate(oraclePubkey, payload, serializer);
254
248
  if (unitPrice !== undefined) {
255
249
  builder = builder.withUnitPrice(unitPrice);
256
250
  }
@@ -267,7 +261,7 @@ class Doppler {
267
261
  const recentBlockhash = yield this.connection.getLatestBlockhash();
268
262
  let builder = this.createTransactionBuilder();
269
263
  for (const update of updates) {
270
- builder = builder.addOracleUpdate(update.oraclePubkey, update.oracle, update.serializer);
264
+ builder = builder.addOracleUpdate(update.oraclePubkey, update.payload, update.serializer);
271
265
  }
272
266
  if (unitPrice !== undefined) {
273
267
  builder = builder.withUnitPrice(unitPrice);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/oracle.ts",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "type": "commonjs",
5
5
  "author": "L0STE, stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {