diff --git a/package.json b/package.json index 482124f..f51d7d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stellar-plus", - "version": "0.5.4", + "version": "0.5.5", "description": "beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/src/stellar-plus/core/contract-engine/index.ts b/src/stellar-plus/core/contract-engine/index.ts index 4c4ec38..8799088 100644 --- a/src/stellar-plus/core/contract-engine/index.ts +++ b/src/stellar-plus/core/contract-engine/index.ts @@ -430,7 +430,8 @@ export class ContractEngine extends SorobanTransactionProcessor { response: await this.processSorobanTransaction( assembledTransaction, updatedTxInvocation.signers, - updatedTxInvocation.feeBump + updatedTxInvocation.feeBump, + updatedTxInvocation.header.timeout ), transactionResources, } diff --git a/src/stellar-plus/core/soroban-transaction-processor/errors.ts b/src/stellar-plus/core/soroban-transaction-processor/errors.ts index b60d143..b1c1db2 100644 --- a/src/stellar-plus/core/soroban-transaction-processor/errors.ts +++ b/src/stellar-plus/core/soroban-transaction-processor/errors.ts @@ -151,14 +151,18 @@ const verifyOpErrorCode = (sorobanGetTransactionData: GetTransactionFailedErrorI const transactionSubmittedNotFound = ( response: SorobanRpc.Api.GetTransactionResponse, - waitTimeout: number + waitTimeout: number, + transactionHash: string ): StellarPlusError => { return new StellarPlusError({ code: SorobanTransactionProcessorErrorCodes.STP007, message: 'Transaction not found!', source: 'SorobanTransactionProcessor', details: `The transaction submitted was not found within the waiting period of ${waitTimeout} ms. Althought the transaction was sent for processing, the subsequent attempts to verify the transaction status didn't succeed to locate it. Review the error message for further information about the failure.`, - meta: { sorobanGetTransactionData: extractGetTransactionData(response) }, + meta: { + transactionHash, + sorobanGetTransactionData: extractGetTransactionData(response), + }, }) } diff --git a/src/stellar-plus/core/soroban-transaction-processor/index.ts b/src/stellar-plus/core/soroban-transaction-processor/index.ts index bb0e7f4..0043f6e 100644 --- a/src/stellar-plus/core/soroban-transaction-processor/index.ts +++ b/src/stellar-plus/core/soroban-transaction-processor/index.ts @@ -153,7 +153,8 @@ export class SorobanTransactionProcessor extends TransactionProcessor { protected async processSorobanTransaction( envelope: Transaction, signers: AccountHandler[], - feeBump?: FeeBumpHeader + feeBump?: FeeBumpHeader, + secondsToWait?: number ): Promise { const signedInnerTransaction = await this.signEnvelope(envelope, signers) @@ -162,7 +163,7 @@ export class SorobanTransactionProcessor extends TransactionProcessor { : (TransactionBuilder.fromXDR(signedInnerTransaction, this.network.networkPassphrase) as Transaction) const rpcResponse = await this.submitTransaction(finalEnvelope) - const processedTransaction = await this.postProcessSorobanSubmission(rpcResponse) + const processedTransaction = await this.postProcessSorobanSubmission(rpcResponse, secondsToWait) return processedTransaction } @@ -176,7 +177,8 @@ export class SorobanTransactionProcessor extends TransactionProcessor { * @returns {Promise} The response from the Soroban server. */ protected async postProcessSorobanSubmission( - response: SorobanRpcNamespace.Api.SendTransactionResponse + response: SorobanRpcNamespace.Api.SendTransactionResponse, + secondsToWait?: number ): Promise { if (response.status === 'ERROR') { throw STPError.failedToSubmitTransactionWithResponse(response) @@ -184,7 +186,7 @@ export class SorobanTransactionProcessor extends TransactionProcessor { if (response.status === 'PENDING' || response.status === 'TRY_AGAIN_LATER') { // console.log('Waiting for Transaction!: ') - return await this.waitForTransaction(response.hash, 15) // Arbitrary 15 seconds timeout + return await this.waitForTransaction(response.hash, secondsToWait ? secondsToWait : 15) // Arbitrary 15 seconds timeout default } throw STPError.failedToVerifyTransactionSubmission(response) @@ -232,7 +234,7 @@ export class SorobanTransactionProcessor extends TransactionProcessor { throw STPError.transactionSubmittedFailed(updatedTransaction) } - throw STPError.transactionSubmittedNotFound(updatedTransaction, timeout) + throw STPError.transactionSubmittedNotFound(updatedTransaction, timeout, transactionHash) } protected postProcessTransaction( diff --git a/src/stellar-plus/error/types.ts b/src/stellar-plus/error/types.ts index 16a5fc4..77963a4 100644 --- a/src/stellar-plus/error/types.ts +++ b/src/stellar-plus/error/types.ts @@ -53,6 +53,7 @@ export type Meta = { data?: object message?: string transactionXDR?: string + transactionHash?: string axiosError?: AxiosErrorInfo transactionData?: TransactionData sorobanSimulationData?: SimulationErrorInfo