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.
- package/browser/_version.d.ts +1 -1
- package/browser/contracts/CallResult.d.ts +1 -0
- package/browser/index.js +1 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/contracts/CallResult.d.ts +1 -0
- package/build/contracts/CallResult.js +37 -34
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/contracts/CallResult.ts +58 -48
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.7.
|
|
1
|
+
export declare const version = "1.7.14";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.7.
|
|
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
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
197
|
-
|
|
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 (!
|
|
200
|
-
throw new Error(`Error sending transaction: ${
|
|
186
|
+
if (!tx1.success) {
|
|
187
|
+
throw new Error(`Error sending transaction: ${tx1.result || 'Unknown error'}`);
|
|
201
188
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.7.
|
|
1
|
+
export const version = '1.7.14';
|
|
@@ -329,67 +329,77 @@ export class CallResult<
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
/**
|
|
332
|
-
*
|
|
333
|
-
* @param {
|
|
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
|
|
338
|
-
|
|
339
|
-
amountAddition: bigint = 0n,
|
|
336
|
+
public async sendPresignedTransaction(
|
|
337
|
+
signedTx: SignedInteractionTransactionReceipt,
|
|
340
338
|
): Promise<InteractionTransactionReceipt> {
|
|
341
|
-
|
|
342
|
-
|
|
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
|
|
364
|
-
signedTx.
|
|
344
|
+
const tx1 = await this.#provider.sendRawTransaction(
|
|
345
|
+
signedTx.fundingTransactionRaw,
|
|
365
346
|
false,
|
|
366
347
|
);
|
|
367
348
|
|
|
368
|
-
if (!
|
|
369
|
-
throw new Error(`Error sending transaction: ${
|
|
349
|
+
if (!tx1 || tx1.error) {
|
|
350
|
+
throw new Error(`Error sending transaction: ${tx1?.error || 'Unknown error'}`);
|
|
370
351
|
}
|
|
371
352
|
|
|
372
|
-
if (!
|
|
373
|
-
throw new Error(
|
|
353
|
+
if (!tx1.success) {
|
|
354
|
+
throw new Error(`Error sending transaction: ${tx1.result || 'Unknown error'}`);
|
|
374
355
|
}
|
|
356
|
+
}
|
|
375
357
|
|
|
376
|
-
|
|
377
|
-
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
|