Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tx execution status #1347

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/silver-chicken-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@near-js/providers": patch
"@near-js/types": patch
---

Update tx execution status default value.
6 changes: 3 additions & 3 deletions packages/providers/src/json-rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class JsonRpcProvider extends Provider {
* @param signedTransaction The signed transaction being sent
*/
async sendTransaction(signedTransaction: SignedTransaction): Promise<FinalExecutionOutcome> {
return this.sendTransactionUntil(signedTransaction, 'FINAL');
return this.sendTransactionUntil(signedTransaction, 'EXECUTED_OPTIMISTIC');
}

/**
Expand All @@ -144,7 +144,7 @@ export class JsonRpcProvider extends Provider {
* @param accountId The NEAR account that signed the transaction
* @param waitUntil
*/
async txStatus(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus = 'FINAL'): Promise<FinalExecutionOutcome> {
async txStatus(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus = 'EXECUTED_OPTIMISTIC'): Promise<FinalExecutionOutcome> {
if (typeof txHash === 'string') {
return this.txStatusString(txHash, accountId, waitUntil);
} else {
Expand All @@ -168,7 +168,7 @@ export class JsonRpcProvider extends Provider {
* @param waitUntil
* @returns {Promise<FinalExecutionOutcome>}
*/
async txStatusReceipts(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus = 'FINAL'): Promise<FinalExecutionOutcome> {
async txStatusReceipts(txHash: Uint8Array | string, accountId: string, waitUntil: TxExecutionStatus = 'EXECUTED_OPTIMISTIC'): Promise<FinalExecutionOutcome> {
if (typeof txHash === 'string') {
return this.sendJsonRpc('EXPERIMENTAL_tx_status', { tx_hash: txHash, sender_account_id: accountId, wait_until: waitUntil });
}
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/provider/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type BlockId = BlockHash | BlockHeight;

export type Finality = 'optimistic' | 'near-final' | 'final'

export type TxExecutionStatus = 'NONE' | 'INCLUDED' | 'INCLUDED_FINAL' | 'EXECUTED' | 'FINAL';
export type TxExecutionStatus = 'NONE' | 'INCLUDED' | 'INCLUDED_FINAL' | 'EXECUTED' | 'FINAL' | 'EXECUTED_OPTIMISTIC';

export type BlockReference = { blockId: BlockId } | { finality: Finality } | { sync_checkpoint: 'genesis' | 'earliest_available' }

Expand Down
Loading