near_api 0.2.3 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/near_api/status.rb +29 -4
- data/lib/near_api/transaction.rb +5 -9
- data/lib/near_api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a142f691dbf68db8700b6e48684f97e8d9106126b56aea18543750f359e56058
|
4
|
+
data.tar.gz: 2a33e90389472f591fe1517e09546bd8172740d6867951381769c72398381302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4509b0f43f7de4f2f01944dd901c23c2f1594d09ef797e0e3c6a3aaf8dfcd1722d4c5d6c5541e1bbed37dfdc37d3b7143f76451374df79d5fc14d38e37d2f2c
|
7
|
+
data.tar.gz: 89b0cfc6ada035f32ac3bc633ec2cfb07d0212844de46e5715ef48e92b241d880e29bb4e1b5ef4218ed7d1b4363936a6d0e866d23a2aadf13d69a78fcf9f5ac7
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.3.1
|
4
|
+
- removed NearApi::Status#final_transaction_status method
|
5
|
+
- added NearApi::Status#transaction_status_with_receipts method
|
6
|
+
- updated NearApi::Status#transaction_status arguments
|
7
|
+
|
8
|
+
## 0.4.1
|
9
|
+
- refactor NearApi::Transaction, replace deprecated `broadcast_tx_async` with `send_tx`
|
10
|
+
- breaking change NearApi::Transaction#call_api arguments
|
data/lib/near_api/status.rb
CHANGED
@@ -1,17 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class NearApi::Status
|
4
|
+
STATUSES = [
|
5
|
+
# Transaction is waiting to be included into the block
|
6
|
+
NONE = 'NONE',
|
7
|
+
|
8
|
+
# Transaction is included into the block. The block may be not finalized yet
|
9
|
+
INCLUDED = 'INCLUDED',
|
10
|
+
|
11
|
+
# Transaction is included into the block +
|
12
|
+
# All non-refund transaction receipts finished their execution.
|
13
|
+
# The corresponding blocks for tx and each receipt may be not finalized yet
|
14
|
+
EXECUTED_OPTIMISTIC = 'EXECUTED_OPTIMISTIC',
|
15
|
+
|
16
|
+
# Transaction is included into finalized block
|
17
|
+
INCLUDED_FINAL = 'INCLUDED_FINAL',
|
18
|
+
|
19
|
+
# Transaction is included into finalized block +
|
20
|
+
# All non-refund transaction receipts finished their execution.
|
21
|
+
# The corresponding blocks for each receipt may be not finalized yet
|
22
|
+
EXECUTED = 'EXECUTED',
|
23
|
+
|
24
|
+
# Transaction is included into finalized block +
|
25
|
+
# Execution of all transaction receipts is finalized, including refund receipts
|
26
|
+
FINAL = 'FINAL'
|
27
|
+
].freeze
|
28
|
+
|
4
29
|
def initialize(config = NearApi.config)
|
5
30
|
@api = NearApi::Api.new(config)
|
6
31
|
end
|
7
32
|
|
8
|
-
def transaction_status(transaction_hash, key: NearApi.key)
|
9
|
-
params =
|
33
|
+
def transaction_status(transaction_hash, wait_until: EXECUTED_OPTIMISTIC, key: NearApi.key)
|
34
|
+
params = { tx_hash: transaction_hash, sender_account_id: key.signer_id, wait_until: wait_until }
|
10
35
|
call_api('tx', params)
|
11
36
|
end
|
12
37
|
|
13
|
-
def
|
14
|
-
params =
|
38
|
+
def transaction_status_with_receipts(transaction_hash, wait_until: EXECUTED_OPTIMISTIC, key: NearApi.key)
|
39
|
+
params = { tx_hash: transaction_hash, sender_account_id: key.signer_id, wait_until: wait_until }
|
15
40
|
call_api('EXPERIMENTAL_tx_status', params)
|
16
41
|
end
|
17
42
|
|
data/lib/near_api/transaction.rb
CHANGED
@@ -27,14 +27,9 @@ module NearApi
|
|
27
27
|
@api = NearApi::Api.new(config)
|
28
28
|
end
|
29
29
|
|
30
|
-
def call
|
30
|
+
def call(wait_until: Status::EXECUTED_OPTIMISTIC)
|
31
31
|
signature = key.sign(message.digest)
|
32
|
-
call_api(
|
33
|
-
end
|
34
|
-
|
35
|
-
def async
|
36
|
-
signature = key.sign(message.digest)
|
37
|
-
call_api('broadcast_tx_async', message.message, signature)
|
32
|
+
call_api(message.message, signature, wait_until: wait_until)
|
38
33
|
end
|
39
34
|
|
40
35
|
def message
|
@@ -48,9 +43,10 @@ module NearApi
|
|
48
43
|
NearApi::Base58.encode(message.digest)
|
49
44
|
end
|
50
45
|
|
51
|
-
def call_api(
|
46
|
+
def call_api(message, signature, wait_until: Status::EXECUTED_OPTIMISTIC)
|
52
47
|
signed_transaction = message + Borsh::Integer.new(key.key_type, :u8).to_borsh + signature
|
53
|
-
|
48
|
+
params = { signed_tx_base64: Base64.strict_encode64(signed_transaction), wait_until: wait_until }
|
49
|
+
api.json_rpc('send_tx', params)
|
54
50
|
end
|
55
51
|
|
56
52
|
private
|
data/lib/near_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: near_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serg Tyatin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07
|
11
|
+
date: 2024-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: borsh-rb
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- ".github/workflows/ci.yml"
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
|
+
- CHANGELOG.md
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE.txt
|
81
82
|
- README.md
|