@near-js/providers
Advanced tools
Comparing version 0.2.0 to 0.2.1
import { AccessKeyWithPublicKey, BlockId, BlockReference, BlockResult, BlockChangeResult, ChangeResult, ChunkId, ChunkResult, EpochValidatorInfo, FinalExecutionOutcome, GasPrice, LightClientProof, LightClientProofRequest, NextLightClientBlockRequest, NextLightClientBlockResponse, NearProtocolConfig, NodeStatusResult, QueryResponseKind, RpcQueryRequest } from '@near-js/types'; | ||
import { SignedTransaction } from '@near-js/transactions'; | ||
import { Provider } from './provider'; | ||
import { TxExecutionStatus } from '@near-js/types/src/provider/protocol'; | ||
/** | ||
@@ -24,2 +25,3 @@ * Client class to interact with the [NEAR RPC API](https://docs.near.org/api/rpc/introduction). | ||
status(): Promise<NodeStatusResult>; | ||
sendTransactionUntil(signedTransaction: SignedTransaction, waitUntil: TxExecutionStatus): Promise<FinalExecutionOutcome>; | ||
/** | ||
@@ -46,3 +48,3 @@ * Sends a signed transaction to the RPC and waits until transaction is fully complete | ||
*/ | ||
txStatus(txHash: Uint8Array | string, accountId: string): Promise<FinalExecutionOutcome>; | ||
txStatus(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus): Promise<FinalExecutionOutcome>; | ||
/** | ||
@@ -55,3 +57,3 @@ * Gets a transaction's status from the RPC with receipts | ||
*/ | ||
txStatusReceipts(txHash: Uint8Array | string, accountId: string): Promise<FinalExecutionOutcome>; | ||
txStatusReceipts(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus): Promise<FinalExecutionOutcome>; | ||
/** | ||
@@ -58,0 +60,0 @@ * Query the RPC by passing an {@link "@near-js/types".provider/request.RpcQueryRequest | RpcQueryRequest } |
@@ -81,2 +81,7 @@ "use strict"; | ||
} | ||
sendTransactionUntil(signedTransaction, waitUntil) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.withBackoff((currentProvider) => currentProvider.sendTransactionUntil(signedTransaction, waitUntil)); | ||
}); | ||
} | ||
/** | ||
@@ -111,5 +116,5 @@ * Sends a signed transaction to the RPC and waits until transaction is fully complete | ||
*/ | ||
txStatus(txHash, accountId) { | ||
txStatus(txHash, accountId, waitUntil) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.withBackoff((currentProvider) => currentProvider.txStatus(txHash, accountId)); | ||
return this.withBackoff((currentProvider) => currentProvider.txStatus(txHash, accountId, waitUntil)); | ||
}); | ||
@@ -124,5 +129,5 @@ } | ||
*/ | ||
txStatusReceipts(txHash, accountId) { | ||
txStatusReceipts(txHash, accountId, waitUntil) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.withBackoff((currentProvider) => currentProvider.txStatusReceipts(txHash, accountId)); | ||
return this.withBackoff((currentProvider) => currentProvider.txStatusReceipts(txHash, accountId, waitUntil)); | ||
}); | ||
@@ -129,0 +134,0 @@ } |
@@ -5,2 +5,3 @@ import { AccessKeyWithPublicKey, BlockId, BlockReference, BlockResult, BlockChangeResult, ChangeResult, ChunkId, ChunkResult, EpochValidatorInfo, FinalExecutionOutcome, GasPrice, LightClientProof, LightClientProofRequest, NextLightClientBlockRequest, NextLightClientBlockResponse, NearProtocolConfig, NodeStatusResult, QueryResponseKind } from '@near-js/types'; | ||
import { ConnectionInfo } from './fetch_json'; | ||
import { TxExecutionStatus } from '@near-js/types/src/provider/protocol'; | ||
type RequestOptions = { | ||
@@ -39,2 +40,9 @@ /** | ||
/** | ||
* Sends a signed transaction to the RPC | ||
* | ||
* @param signedTransaction The signed transaction being sent | ||
* @param waitUntil | ||
*/ | ||
sendTransactionUntil(signedTransaction: SignedTransaction, waitUntil: TxExecutionStatus): Promise<FinalExecutionOutcome>; | ||
/** | ||
* Sends a signed transaction to the RPC and waits until transaction is fully complete | ||
@@ -59,4 +67,5 @@ * @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) | ||
* @param accountId The NEAR account that signed the transaction | ||
* @param waitUntil | ||
*/ | ||
txStatus(txHash: Uint8Array | string, accountId: string): Promise<FinalExecutionOutcome>; | ||
txStatus(txHash: Uint8Array | string, accountId: string, waitUntil?: TxExecutionStatus): Promise<FinalExecutionOutcome>; | ||
private txStatusUint8Array; | ||
@@ -69,5 +78,6 @@ private txStatusString; | ||
* @param accountId The NEAR account that signed the transaction | ||
* @param waitUntil | ||
* @returns {Promise<FinalExecutionOutcome>} | ||
*/ | ||
txStatusReceipts(txHash: Uint8Array | string, accountId: string): Promise<FinalExecutionOutcome>; | ||
txStatusReceipts(txHash: Uint8Array | string, accountId: string, waitUntil?: TxExecutionStatus): Promise<FinalExecutionOutcome>; | ||
/** | ||
@@ -74,0 +84,0 @@ * Query the RPC by passing an {@link "@near-js/types".provider/request.RpcQueryRequest | RpcQueryRequest } |
@@ -74,2 +74,14 @@ "use strict"; | ||
/** | ||
* Sends a signed transaction to the RPC | ||
* | ||
* @param signedTransaction The signed transaction being sent | ||
* @param waitUntil | ||
*/ | ||
sendTransactionUntil(signedTransaction, waitUntil) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const bytes = (0, transactions_1.encodeTransaction)(signedTransaction); | ||
return this.sendJsonRpc('send_tx', { signed_tx_base64: Buffer.from(bytes).toString('base64'), wait_until: waitUntil }); | ||
}); | ||
} | ||
/** | ||
* Sends a signed transaction to the RPC and waits until transaction is fully complete | ||
@@ -82,4 +94,3 @@ * @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) | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const bytes = (0, transactions_1.encodeTransaction)(signedTransaction); | ||
return this.sendJsonRpc('broadcast_tx_commit', [Buffer.from(bytes).toString('base64')]); | ||
return this.sendTransactionUntil(signedTransaction, 'FINAL'); | ||
}); | ||
@@ -95,4 +106,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const bytes = (0, transactions_1.encodeTransaction)(signedTransaction); | ||
return this.sendJsonRpc('broadcast_tx_async', [Buffer.from(bytes).toString('base64')]); | ||
return this.sendTransactionUntil(signedTransaction, 'NONE'); | ||
}); | ||
@@ -106,21 +116,22 @@ } | ||
* @param accountId The NEAR account that signed the transaction | ||
* @param waitUntil | ||
*/ | ||
txStatus(txHash, accountId) { | ||
txStatus(txHash, accountId, waitUntil = 'FINAL') { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof txHash === 'string') { | ||
return this.txStatusString(txHash, accountId); | ||
return this.txStatusString(txHash, accountId, waitUntil); | ||
} | ||
else { | ||
return this.txStatusUint8Array(txHash, accountId); | ||
return this.txStatusUint8Array(txHash, accountId, waitUntil); | ||
} | ||
}); | ||
} | ||
txStatusUint8Array(txHash, accountId) { | ||
txStatusUint8Array(txHash, accountId, waitUntil) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.sendJsonRpc('tx', [(0, utils_1.baseEncode)(txHash), accountId]); | ||
return this.sendJsonRpc('tx', { tx_hash: (0, utils_1.baseEncode)(txHash), sender_account_id: accountId, wait_until: waitUntil }); | ||
}); | ||
} | ||
txStatusString(txHash, accountId) { | ||
txStatusString(txHash, accountId, waitUntil) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.sendJsonRpc('tx', [txHash, accountId]); | ||
return this.sendJsonRpc('tx', { tx_hash: txHash, sender_account_id: accountId, wait_until: waitUntil }); | ||
}); | ||
@@ -133,11 +144,12 @@ } | ||
* @param accountId The NEAR account that signed the transaction | ||
* @param waitUntil | ||
* @returns {Promise<FinalExecutionOutcome>} | ||
*/ | ||
txStatusReceipts(txHash, accountId) { | ||
txStatusReceipts(txHash, accountId, waitUntil = 'FINAL') { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof txHash === 'string') { | ||
return this.sendJsonRpc('EXPERIMENTAL_tx_status', [txHash, accountId]); | ||
return this.sendJsonRpc('EXPERIMENTAL_tx_status', { tx_hash: txHash, sender_account_id: accountId, wait_until: waitUntil }); | ||
} | ||
else { | ||
return this.sendJsonRpc('EXPERIMENTAL_tx_status', [(0, utils_1.baseEncode)(txHash), accountId]); | ||
return this.sendJsonRpc('EXPERIMENTAL_tx_status', { tx_hash: (0, utils_1.baseEncode)(txHash), sender_account_id: accountId, wait_until: waitUntil }); | ||
} | ||
@@ -144,0 +156,0 @@ }); |
@@ -7,9 +7,11 @@ /** | ||
import { AccessKeyWithPublicKey, BlockChangeResult, BlockId, BlockReference, BlockResult, ChangeResult, ChunkId, ChunkResult, FinalExecutionOutcome, GasPrice, LightClientProof, LightClientProofRequest, NextLightClientBlockRequest, NextLightClientBlockResponse, NearProtocolConfig, NodeStatusResult, QueryResponseKind, RpcQueryRequest, EpochValidatorInfo } from '@near-js/types'; | ||
import { TxExecutionStatus } from '@near-js/types/src/provider/protocol'; | ||
/** @hidden */ | ||
export declare 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>; | ||
@@ -16,0 +18,0 @@ abstract query<T extends QueryResponseKind>(path: string, data: string): Promise<T>; |
{ | ||
"name": "@near-js/providers", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Library of implementations for interfacing with the NEAR blockchain", | ||
@@ -12,5 +12,5 @@ "main": "lib/index.js", | ||
"http-errors": "1.7.2", | ||
"@near-js/transactions": "1.2.0", | ||
"@near-js/types": "0.1.0", | ||
"@near-js/utils": "0.2.0" | ||
"@near-js/transactions": "1.2.1", | ||
"@near-js/types": "0.2.0", | ||
"@near-js/utils": "0.2.1" | ||
}, | ||
@@ -20,3 +20,3 @@ "devDependencies": { | ||
"jest": "26.0.1", | ||
"near-workspaces": "3.4.0", | ||
"near-workspaces": "3.5.0", | ||
"ts-jest": "26.5.6", | ||
@@ -31,2 +31,6 @@ "typescript": "4.9.4" | ||
], | ||
"resolutions": { | ||
"near-sandbox": "0.0.18", | ||
"near-api-js": "4.0.0" | ||
}, | ||
"scripts": { | ||
@@ -33,0 +37,0 @@ "build": "pnpm compile", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76970
1286
11
+ Added@near-js/crypto@1.2.3(transitive)
+ Added@near-js/keystores@0.0.11(transitive)
+ Added@near-js/signers@0.1.3(transitive)
+ Added@near-js/transactions@1.2.1(transitive)
+ Added@near-js/types@0.2.0(transitive)
+ Added@near-js/utils@0.2.1(transitive)
- Removed@near-js/crypto@1.2.2(transitive)
- Removed@near-js/keystores@0.0.10(transitive)
- Removed@near-js/signers@0.1.2(transitive)
- Removed@near-js/transactions@1.2.0(transitive)
- Removed@near-js/types@0.1.0(transitive)
- Removed@near-js/utils@0.2.0(transitive)
Updated@near-js/transactions@1.2.1
Updated@near-js/types@0.2.0
Updated@near-js/utils@0.2.1