Skip to content

Commit

Permalink
fix: revert provider changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gtsonevv committed Apr 23, 2024
1 parent 3f7730a commit fa4f29f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 11 additions & 4 deletions packages/providers/src/failover-rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -106,6 +107,10 @@ export class FailoverRpcProvider extends Provider {
return this.withBackoff((currentProvider) => currentProvider.status());
}

async sendTransactionUntil(signedTransaction: SignedTransaction, waitUntil: TxExecutionStatus): Promise<FinalExecutionOutcome> {
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)
Expand Down Expand Up @@ -141,9 +146,10 @@ export class FailoverRpcProvider extends Provider {
*/
async txStatus(
txHash: Uint8Array | string,
accountId: string
accountId: string,
waitUntil: TxExecutionStatus
): Promise<FinalExecutionOutcome> {
return this.withBackoff((currentProvider) => currentProvider.txStatus(txHash, accountId)
return this.withBackoff((currentProvider) => currentProvider.txStatus(txHash, accountId, waitUntil)
);
}

Expand All @@ -156,9 +162,10 @@ export class FailoverRpcProvider extends Provider {
*/
async txStatusReceipts(
txHash: Uint8Array | string,
accountId: string
accountId: string,
waitUntil: TxExecutionStatus
): Promise<FinalExecutionOutcome> {
return this.withBackoff((currentProvider) => currentProvider.txStatusReceipts(txHash, accountId)
return this.withBackoff((currentProvider) => currentProvider.txStatusReceipts(txHash, accountId, waitUntil)
);
}

Expand Down
6 changes: 4 additions & 2 deletions packages/providers/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<NodeStatusResult>;

abstract sendTransactionUntil(signedTransaction: SignedTransaction, waitUntil: TxExecutionStatus): Promise<FinalExecutionOutcome>;
abstract sendTransaction(signedTransaction: SignedTransaction): Promise<FinalExecutionOutcome>;
abstract sendTransactionAsync(signedTransaction: SignedTransaction): Promise<FinalExecutionOutcome>;
abstract txStatus(txHash: Uint8Array | string, accountId: string): Promise<FinalExecutionOutcome>;
abstract txStatusReceipts(txHash: Uint8Array | string, accountId: string): Promise<FinalExecutionOutcome>;
abstract txStatus(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus): Promise<FinalExecutionOutcome>;
abstract txStatusReceipts(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus): Promise<FinalExecutionOutcome>;
abstract query<T extends QueryResponseKind>(params: RpcQueryRequest): Promise<T>;
abstract query<T extends QueryResponseKind>(path: string, data: string): Promise<T>;
// TODO: BlockQuery type?
Expand Down

0 comments on commit fa4f29f

Please sign in to comment.