Skip to content

Commit

Permalink
refactor status
Browse files Browse the repository at this point in the history
  • Loading branch information
Meta Head committed Aug 6, 2024
1 parent 9f17f6f commit 2915fe0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Change Log

## 0.3.1
- removed NearApi::Status#final_transaction_status method
- added NearApi::Status#transaction_status_with_receipts method
- updated NearApi::Status#transaction_status arguments
33 changes: 29 additions & 4 deletions lib/near_api/status.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
# frozen_string_literal: true

class NearApi::Status
STATUSES = [
# Transaction is waiting to be included into the block
NONE = 'NONE',

# Transaction is included into the block. The block may be not finalized yet
INCLUDED = 'INCLUDED',

# Transaction is included into the block +
# All non-refund transaction receipts finished their execution.
# The corresponding blocks for tx and each receipt may be not finalized yet
EXECUTED_OPTIMISTIC = 'EXECUTED_OPTIMISTIC',

# Transaction is included into finalized block
INCLUDED_FINAL = 'INCLUDED_FINAL',

# Transaction is included into finalized block +
# All non-refund transaction receipts finished their execution.
# The corresponding blocks for each receipt may be not finalized yet
EXECUTED = 'EXECUTED',

# Transaction is included into finalized block +
# Execution of all transaction receipts is finalized, including refund receipts
FINAL = 'FINAL'
].freeze

def initialize(config = NearApi.config)
@api = NearApi::Api.new(config)
end

def transaction_status(transaction_hash, key: NearApi.key)
params = [transaction_hash, key.signer_id]
def transaction_status(transaction_hash, wait_until: EXECUTED_OPTIMISTIC, key: NearApi.key)
params = { tx_hash: transaction_hash, sender_account_id: key.signer_id, wait_until: wait_until }
call_api('tx', params)
end

def final_transaction_status(transaction_hash, key: NearApi.key)
params = [transaction_hash, key.signer_id]
def transaction_status_with_receipts(transaction_hash, wait_until: EXECUTED_OPTIMISTIC, key: NearApi.key)
params = { tx_hash: transaction_hash, sender_account_id: key.signer_id, wait_until: wait_until }
call_api('EXPERIMENTAL_tx_status', params)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/near_api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module NearApi
VERSION = '0.2.3'
VERSION = '0.3.1'
end

0 comments on commit 2915fe0

Please sign in to comment.