diff --git a/packages/providers/src/failover-rpc-provider.ts b/packages/providers/src/failover-rpc-provider.ts index 9a07edfd9f..4729f89c06 100644 --- a/packages/providers/src/failover-rpc-provider.ts +++ b/packages/providers/src/failover-rpc-provider.ts @@ -30,6 +30,7 @@ import { } from '@near-js/types'; import { SignedTransaction } from '@near-js/transactions'; import { Provider } from './provider'; +import { TxExecutionStatus } from '@near-js/types/src/provider/protocol'; /** * Client class to interact with the [NEAR RPC API](https://docs.near.org/api/rpc/introduction). @@ -106,6 +107,10 @@ export class FailoverRpcProvider extends Provider { return this.withBackoff((currentProvider) => currentProvider.status()); } + async sendTransactionUntil(signedTransaction: SignedTransaction, waitUntil: TxExecutionStatus): Promise { + return this.withBackoff((currentProvider) => currentProvider.sendTransactionUntil(signedTransaction, waitUntil)); + } + /** * Sends a signed transaction to the RPC and waits until transaction is fully complete * @see [https://docs.near.org/docs/develop/front-end/rpc#send-transaction-await](https://docs.near.org/docs/develop/front-end/rpc#general-validator-status) @@ -141,9 +146,10 @@ export class FailoverRpcProvider extends Provider { */ async txStatus( txHash: Uint8Array | string, - accountId: string + accountId: string, + waitUntil: TxExecutionStatus ): Promise { - return this.withBackoff((currentProvider) => currentProvider.txStatus(txHash, accountId) + return this.withBackoff((currentProvider) => currentProvider.txStatus(txHash, accountId, waitUntil) ); } @@ -156,9 +162,10 @@ export class FailoverRpcProvider extends Provider { */ async txStatusReceipts( txHash: Uint8Array | string, - accountId: string + accountId: string, + waitUntil: TxExecutionStatus ): Promise { - return this.withBackoff((currentProvider) => currentProvider.txStatusReceipts(txHash, accountId) + return this.withBackoff((currentProvider) => currentProvider.txStatusReceipts(txHash, accountId, waitUntil) ); } diff --git a/packages/providers/src/provider.ts b/packages/providers/src/provider.ts index 6ce137149b..f17af6df45 100644 --- a/packages/providers/src/provider.ts +++ b/packages/providers/src/provider.ts @@ -25,15 +25,17 @@ import { RpcQueryRequest, EpochValidatorInfo, } from '@near-js/types'; +import { TxExecutionStatus } from '@near-js/types/src/provider/protocol'; /** @hidden */ export abstract class Provider { abstract status(): Promise; + abstract sendTransactionUntil(signedTransaction: SignedTransaction, waitUntil: TxExecutionStatus): Promise; abstract sendTransaction(signedTransaction: SignedTransaction): Promise; abstract sendTransactionAsync(signedTransaction: SignedTransaction): Promise; - abstract txStatus(txHash: Uint8Array | string, accountId: string): Promise; - abstract txStatusReceipts(txHash: Uint8Array | string, accountId: string): Promise; + abstract txStatus(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus): Promise; + abstract txStatusReceipts(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus): Promise; abstract query(params: RpcQueryRequest): Promise; abstract query(path: string, data: string): Promise; // TODO: BlockQuery type?