opnet 1.7.13 → 1.7.14

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.
@@ -1 +1 @@
1
- export declare const version = "1.7.13";
1
+ export declare const version = "1.7.14";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.7.13';
1
+ export const version = '1.7.14';
@@ -94,6 +94,7 @@ export declare class CallResult<T extends ContractDecodedObjectResult = {}, U ex
94
94
  setTo(to: string, address: Address): void;
95
95
  setFromAddress(from?: Address): void;
96
96
  signTransaction(interactionParams: TransactionParameters, amountAddition?: bigint): Promise<SignedInteractionTransactionReceipt>;
97
+ sendPresignedTransaction(signedTx: SignedInteractionTransactionReceipt): Promise<InteractionTransactionReceipt>;
97
98
  sendTransaction(interactionParams: TransactionParameters, amountAddition?: bigint): Promise<InteractionTransactionReceipt>;
98
99
  setGasEstimation(estimatedGas: bigint, refundedGas: bigint): void;
99
100
  setBitcoinFee(fees: BitcoinFees): void;
@@ -174,43 +174,46 @@ export class CallResult {
174
174
  utxoTracking,
175
175
  };
176
176
  }
177
- async sendTransaction(interactionParams, amountAddition = 0n) {
178
- try {
179
- const signedTx = await this.signTransaction(interactionParams, amountAddition);
180
- if (!signedTx.utxoTracking.isP2WDA) {
181
- if (!signedTx.fundingTransactionRaw) {
182
- throw new Error('Funding transaction not created');
183
- }
184
- const tx1 = await this.#provider.sendRawTransaction(signedTx.fundingTransactionRaw, false);
185
- if (!tx1 || tx1.error) {
186
- throw new Error(`Error sending transaction: ${tx1?.error || 'Unknown error'}`);
187
- }
188
- if (!tx1.success) {
189
- throw new Error(`Error sending transaction: ${tx1.result || 'Unknown error'}`);
190
- }
191
- }
192
- const tx2 = await this.#provider.sendRawTransaction(signedTx.interactionTransactionRaw, false);
193
- if (!tx2 || tx2.error) {
194
- throw new Error(`Error sending transaction: ${tx2?.error || 'Unknown error'}`);
177
+ async sendPresignedTransaction(signedTx) {
178
+ if (!signedTx.utxoTracking.isP2WDA) {
179
+ if (!signedTx.fundingTransactionRaw) {
180
+ throw new Error('Funding transaction not created');
195
181
  }
196
- if (!tx2.result) {
197
- throw new Error('No transaction ID returned');
182
+ const tx1 = await this.#provider.sendRawTransaction(signedTx.fundingTransactionRaw, false);
183
+ if (!tx1 || tx1.error) {
184
+ throw new Error(`Error sending transaction: ${tx1?.error || 'Unknown error'}`);
198
185
  }
199
- if (!tx2.success) {
200
- throw new Error(`Error sending transaction: ${tx2.result || 'Unknown error'}`);
186
+ if (!tx1.success) {
187
+ throw new Error(`Error sending transaction: ${tx1.result || 'Unknown error'}`);
201
188
  }
202
- this.#processUTXOTracking(signedTx);
203
- return {
204
- interactionAddress: signedTx.interactionAddress,
205
- transactionId: tx2.result,
206
- peerAcknowledgements: tx2.peers || 0,
207
- newUTXOs: signedTx.nextUTXOs,
208
- estimatedFees: signedTx.estimatedFees,
209
- challengeSolution: signedTx.challengeSolution,
210
- rawTransaction: signedTx.interactionTransactionRaw,
211
- fundingUTXOs: signedTx.fundingUTXOs,
212
- compiledTargetScript: signedTx.compiledTargetScript,
213
- };
189
+ }
190
+ const tx2 = await this.#provider.sendRawTransaction(signedTx.interactionTransactionRaw, false);
191
+ if (!tx2 || tx2.error) {
192
+ throw new Error(`Error sending transaction: ${tx2?.error || 'Unknown error'}`);
193
+ }
194
+ if (!tx2.result) {
195
+ throw new Error('No transaction ID returned');
196
+ }
197
+ if (!tx2.success) {
198
+ throw new Error(`Error sending transaction: ${tx2.result || 'Unknown error'}`);
199
+ }
200
+ this.#processUTXOTracking(signedTx);
201
+ return {
202
+ interactionAddress: signedTx.interactionAddress,
203
+ transactionId: tx2.result,
204
+ peerAcknowledgements: tx2.peers || 0,
205
+ newUTXOs: signedTx.nextUTXOs,
206
+ estimatedFees: signedTx.estimatedFees,
207
+ challengeSolution: signedTx.challengeSolution,
208
+ rawTransaction: signedTx.interactionTransactionRaw,
209
+ fundingUTXOs: signedTx.fundingUTXOs,
210
+ compiledTargetScript: signedTx.compiledTargetScript,
211
+ };
212
+ }
213
+ async sendTransaction(interactionParams, amountAddition = 0n) {
214
+ try {
215
+ const signedTx = await this.signTransaction(interactionParams, amountAddition);
216
+ return await this.sendPresignedTransaction(signedTx);
214
217
  }
215
218
  catch (e) {
216
219
  const msgStr = e.message;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opnet",
3
3
  "type": "module",
4
- "version": "1.7.13",
4
+ "version": "1.7.14",
5
5
  "author": "OP_NET",
6
6
  "description": "The perfect library for building Bitcoin-based applications.",
7
7
  "engines": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.7.13';
1
+ export const version = '1.7.14';
@@ -329,67 +329,77 @@ export class CallResult<
329
329
  }
330
330
 
331
331
  /**
332
- * Signs and broadcasts a bitcoin interaction transaction from a simulated contract call.
333
- * @param {TransactionParameters} interactionParams - The parameters for the transaction.
334
- * @param amountAddition - Additional satoshis to request when acquiring UTXOs.
332
+ * Broadcasts a pre-signed interaction transaction.
333
+ * @param {SignedInteractionTransactionReceipt} signedTx - The signed transaction data.
335
334
  * @returns {Promise<InteractionTransactionReceipt>} The transaction receipt with broadcast results.
336
335
  */
337
- public async sendTransaction(
338
- interactionParams: TransactionParameters,
339
- amountAddition: bigint = 0n,
336
+ public async sendPresignedTransaction(
337
+ signedTx: SignedInteractionTransactionReceipt,
340
338
  ): Promise<InteractionTransactionReceipt> {
341
- try {
342
- const signedTx = await this.signTransaction(interactionParams, amountAddition);
343
-
344
- if (!signedTx.utxoTracking.isP2WDA) {
345
- if (!signedTx.fundingTransactionRaw) {
346
- throw new Error('Funding transaction not created');
347
- }
348
-
349
- const tx1 = await this.#provider.sendRawTransaction(
350
- signedTx.fundingTransactionRaw,
351
- false,
352
- );
353
-
354
- if (!tx1 || tx1.error) {
355
- throw new Error(`Error sending transaction: ${tx1?.error || 'Unknown error'}`);
356
- }
357
-
358
- if (!tx1.success) {
359
- throw new Error(`Error sending transaction: ${tx1.result || 'Unknown error'}`);
360
- }
339
+ if (!signedTx.utxoTracking.isP2WDA) {
340
+ if (!signedTx.fundingTransactionRaw) {
341
+ throw new Error('Funding transaction not created');
361
342
  }
362
343
 
363
- const tx2 = await this.#provider.sendRawTransaction(
364
- signedTx.interactionTransactionRaw,
344
+ const tx1 = await this.#provider.sendRawTransaction(
345
+ signedTx.fundingTransactionRaw,
365
346
  false,
366
347
  );
367
348
 
368
- if (!tx2 || tx2.error) {
369
- throw new Error(`Error sending transaction: ${tx2?.error || 'Unknown error'}`);
349
+ if (!tx1 || tx1.error) {
350
+ throw new Error(`Error sending transaction: ${tx1?.error || 'Unknown error'}`);
370
351
  }
371
352
 
372
- if (!tx2.result) {
373
- throw new Error('No transaction ID returned');
353
+ if (!tx1.success) {
354
+ throw new Error(`Error sending transaction: ${tx1.result || 'Unknown error'}`);
374
355
  }
356
+ }
375
357
 
376
- if (!tx2.success) {
377
- throw new Error(`Error sending transaction: ${tx2.result || 'Unknown error'}`);
378
- }
358
+ const tx2 = await this.#provider.sendRawTransaction(
359
+ signedTx.interactionTransactionRaw,
360
+ false,
361
+ );
362
+
363
+ if (!tx2 || tx2.error) {
364
+ throw new Error(`Error sending transaction: ${tx2?.error || 'Unknown error'}`);
365
+ }
379
366
 
380
- this.#processUTXOTracking(signedTx);
381
-
382
- return {
383
- interactionAddress: signedTx.interactionAddress,
384
- transactionId: tx2.result,
385
- peerAcknowledgements: tx2.peers || 0,
386
- newUTXOs: signedTx.nextUTXOs,
387
- estimatedFees: signedTx.estimatedFees,
388
- challengeSolution: signedTx.challengeSolution,
389
- rawTransaction: signedTx.interactionTransactionRaw,
390
- fundingUTXOs: signedTx.fundingUTXOs,
391
- compiledTargetScript: signedTx.compiledTargetScript,
392
- };
367
+ if (!tx2.result) {
368
+ throw new Error('No transaction ID returned');
369
+ }
370
+
371
+ if (!tx2.success) {
372
+ throw new Error(`Error sending transaction: ${tx2.result || 'Unknown error'}`);
373
+ }
374
+
375
+ this.#processUTXOTracking(signedTx);
376
+
377
+ return {
378
+ interactionAddress: signedTx.interactionAddress,
379
+ transactionId: tx2.result,
380
+ peerAcknowledgements: tx2.peers || 0,
381
+ newUTXOs: signedTx.nextUTXOs,
382
+ estimatedFees: signedTx.estimatedFees,
383
+ challengeSolution: signedTx.challengeSolution,
384
+ rawTransaction: signedTx.interactionTransactionRaw,
385
+ fundingUTXOs: signedTx.fundingUTXOs,
386
+ compiledTargetScript: signedTx.compiledTargetScript,
387
+ };
388
+ }
389
+
390
+ /**
391
+ * Signs and broadcasts a bitcoin interaction transaction from a simulated contract call.
392
+ * @param {TransactionParameters} interactionParams - The parameters for the transaction.
393
+ * @param amountAddition - Additional satoshis to request when acquiring UTXOs.
394
+ * @returns {Promise<InteractionTransactionReceipt>} The transaction receipt with broadcast results.
395
+ */
396
+ public async sendTransaction(
397
+ interactionParams: TransactionParameters,
398
+ amountAddition: bigint = 0n,
399
+ ): Promise<InteractionTransactionReceipt> {
400
+ try {
401
+ const signedTx = await this.signTransaction(interactionParams, amountAddition);
402
+ return await this.sendPresignedTransaction(signedTx);
393
403
  } catch (e) {
394
404
  const msgStr = (e as Error).message;
395
405