near 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 147f21ee313f56cb2e1327e8817df79796dd56fe90eff771e9057e6d7248c4f5
4
- data.tar.gz: bf81f3240cb7e18c519d85696bf472b1bf2c8e56c3049aa942fe2aaae37e38f6
3
+ metadata.gz: 1d113e40c4ca1414cd8bff319acdaeba7d7cd1a07ebc866ce875afd2080e44b1
4
+ data.tar.gz: ae7151a4a1022ecf3b9d652ae11bcabfffc427ccaad0cc07858fd662fb91cbd8
5
5
  SHA512:
6
- metadata.gz: 4cfef8be7777c9dd2f2f839284581a44a0f2479f256f09e759628c21509a6d3bc9b95ad07c7e0e13a2e8c22aa5238bd826a224cdac9c6e649388bd060971569d
7
- data.tar.gz: 4c5e69608fe79e7a1e0f7a9046477ea9c590d61d1ee6bf12b530054775fc26464d68ddd29c6c9655f05459faf2752a4c7119e5a29afb17a2500ba115618d0b3d
6
+ metadata.gz: 779325138cf044d38991e1911d8bf115f8559d86a530bda11e0b97a75367406386b63e81a7e9a3d9db69b70ab826ce146e0b326efdb9e69dcf3545083227c1bb
7
+ data.tar.gz: f5b55100bc19a9c8d3e6c165e66d7780b94a60ed1fea90bce0523cf77657b384b13c1439c8aabbc4db2b6d2ae5534ef186ad9d7ed82dd2bb3e85ee915f5e1fb0
data/CHANGES.md CHANGED
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.3.1 - 2025-02-05
9
+
8
10
  ## 0.3.0 - 2025-02-02
9
11
 
10
12
  ### Added
data/README.md CHANGED
@@ -6,12 +6,13 @@
6
6
  [![Documentation](https://img.shields.io/badge/rubydoc-latest-blue)](https://rubydoc.info/gems/near)
7
7
 
8
8
  **NEAR.rb** is a [Ruby] client library for the [NEAR Protocol].
9
- It provides a [neardata.xyz] API client as well as wraps the
10
- [NEAR command-line interface] (CLI) in a usable Ruby interface.
9
+ It provides a [neardata.xyz] API client for block data as well as wraps the
10
+ [NEAR Command-Line Interface] (CLI) in a high-productivity Ruby interface.
11
11
 
12
12
  ## ✨ Features
13
13
 
14
14
  - Fetches block data from the [neardata.xyz] API.
15
+ - Supports parsing of block, chunk, transaction, and action data.
15
16
  - Wraps the complete CLI features in an idiomatic Ruby interface.
16
17
  - Provides comprehensive account management operations.
17
18
  - Supports token operations for NEAR and other assets.
@@ -25,7 +26,7 @@ It provides a [neardata.xyz] API client as well as wraps the
25
26
 
26
27
  ## 🛠️ Prerequisites
27
28
 
28
- - [NEAR CLI] 0.19+
29
+ - [NEAR CLI] 0.18+
29
30
  - [Ruby] 3.0+
30
31
 
31
32
  ## ⬇️ Installation
@@ -84,8 +85,6 @@ end
84
85
 
85
86
  ### Tracking chain transactions
86
87
 
87
- See [`examples/monitor_all_transactions.rb`](examples/monitor_all_transactions.rb).
88
-
89
88
  ```ruby
90
89
  NEAR.testnet.fetch_blocks do |block|
91
90
  puts block.inspect
@@ -96,9 +95,12 @@ NEAR.testnet.fetch_blocks do |block|
96
95
  end
97
96
  ```
98
97
 
99
- ### Tracking chain actions
98
+ For a more elaborated example, see
99
+ [`examples/monitor_all_transactions.rb`](examples/monitor_all_transactions.rb):
100
100
 
101
- See [`examples/monitor_all_actions.rb`](examples/monitor_all_actions.rb).
101
+ [![monitor_all_transactions.rb](examples/monitor_all_transactions.gif)](examples/monitor_all_transactions.gif)
102
+
103
+ ### Tracking chain actions
102
104
 
103
105
  ```ruby
104
106
  NEAR.testnet.fetch_blocks do |block|
@@ -110,9 +112,12 @@ NEAR.testnet.fetch_blocks do |block|
110
112
  end
111
113
  ```
112
114
 
113
- ### Tracking contract interactions
115
+ For a more elaborated example, see
116
+ [`examples/monitor_all_actions.rb`](examples/monitor_all_actions.rb):
114
117
 
115
- See [`examples/index_evm_transactions.rb`](examples/index_evm_transactions.rb).
118
+ [![monitor_all_actions.rb](examples/monitor_all_actions.gif)](examples/monitor_all_actions.gif)
119
+
120
+ ### Tracking contract interactions
116
121
 
117
122
  ```ruby
118
123
  NEAR.testnet.fetch_blocks do |block|
@@ -124,6 +129,11 @@ NEAR.testnet.fetch_blocks do |block|
124
129
  end
125
130
  ```
126
131
 
132
+ For a more elaborated example, see
133
+ [`examples/index_evm_transactions.rb`](examples/index_evm_transactions.rb):
134
+
135
+ [![index_evm_transactions.rb](examples/index_evm_transactions.gif)](examples/index_evm_transactions.gif)
136
+
127
137
  ### Instantiating the CLI wrapper
128
138
 
129
139
  ```ruby
@@ -177,7 +187,7 @@ result = testnet.import_account_with_private_key(
177
187
  # Create an account funded from a faucet (testnet only):
178
188
  result = testnet.create_account_with_faucet(
179
189
  'mynewaccount.testnet',
180
- 'ed25519:HVPgAsZkZ7cwLZDqK313XJsDyqAvgBxrATcD7VacA8KE'
190
+ public_key: 'ed25519:HVPgAsZkZ7cwLZDqK313XJsDyqAvgBxrATcD7VacA8KE'
181
191
  )
182
192
 
183
193
  # Create an account funded by another account:
@@ -197,8 +207,8 @@ result = testnet.create_implicit_account('/path/to/credentials/folder')
197
207
  ```ruby
198
208
  # Delete an existing account:
199
209
  result = testnet.delete_account(
200
- 'todelete.testnet', # account to delete
201
- 'beneficiary.testnet' # account receiving remaining balance
210
+ 'my-obsolete-account.testnet', # account to delete
211
+ beneficiary: 'v2.faucet.nonofficial.testnet' # account receiving remaining balance
202
212
  )
203
213
  ```
204
214
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/lib/near/account.rb CHANGED
@@ -5,10 +5,20 @@
5
5
  #
6
6
  # @see https://nomicon.io/DataStructures/Account
7
7
  class NEAR::Account
8
+ ##
9
+ # @param [String, #to_s] id
10
+ # @return [NEAR::Account]
8
11
  def self.parse(id)
9
12
  self.new(id.to_s)
10
13
  end
11
14
 
15
+ ##
16
+ # @return [NEAR::Account]
17
+ def self.temp
18
+ timestamp = (Time.now.to_f * 1_000).to_i
19
+ self.new("temp-#{timestamp}.testnet")
20
+ end
21
+
12
22
  ##
13
23
  # @param [String, #to_s] id
14
24
  def initialize(id)
@@ -70,15 +70,20 @@ module NEAR::CLI::Account
70
70
  ##
71
71
  # Creates a new account sponsored by the faucet service.
72
72
  #
73
- # @param [String] new_account_id
74
- # @param [String] public_key
73
+ # @param [NEAR::Account, #to_s] new_account
74
+ # @param [String, nil] public_key
75
75
  # @return [String]
76
- def create_account_with_faucet(new_account_id, public_key)
76
+ def create_account_with_faucet(new_account, public_key: nil)
77
77
  stdout, stderr = execute(
78
78
  'account',
79
79
  'create-account',
80
- 'sponsor-by-faucet-service', new_account_id,
81
- 'use-manually-provided-public-key', public_key,
80
+ 'sponsor-by-faucet-service', new_account.to_s,
81
+ *case public_key
82
+ when nil then ['autogenerate-new-keypair', 'save-to-keychain']
83
+ when String then ['use-manually-provided-public-key', public_key]
84
+ when Array then public_key
85
+ else raise ArgumentError
86
+ end,
82
87
  'network-config', @network,
83
88
  'create'
84
89
  )
@@ -88,16 +93,22 @@ module NEAR::CLI::Account
88
93
  ##
89
94
  # Creates a new account funded by another account.
90
95
  #
91
- # @param [NEAR::Account] new_account
92
- # @param [NEAR::Account] signer Account that signs & funds the transaction
93
- # @param [NEAR::Balance] deposit Amount of NEAR to attach
96
+ # @param [NEAR::Account, #to_s] new_account
97
+ # @param [NEAR::Account, #to_s] signer Account that signs & funds the transaction
98
+ # @param [String, nil] public_key
99
+ # @param [NEAR::Balance, #to_s] deposit Amount of NEAR to attach
94
100
  # @return [String]
95
- def create_account_with_funding(new_account, signer:, deposit: nil)
101
+ def create_account_with_funding(new_account, signer:, public_key: nil, deposit: nil)
96
102
  stdout, stderr = execute(
97
103
  'account',
98
104
  'create-account',
99
105
  'fund-myself', new_account.to_s, (deposit ? deposit.to_s : '0') + ' NEAR',
100
- 'autogenerate-new-keypair', 'save-to-keychain',
106
+ *case public_key
107
+ when nil then ['autogenerate-new-keypair', 'save-to-keychain']
108
+ when String then ['use-manually-provided-public-key', public_key]
109
+ when Array then public_key
110
+ else raise ArgumentError
111
+ end,
101
112
  'sign-as', signer.to_s,
102
113
  'network-config', @network,
103
114
  'sign-with-keychain',
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: near
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-02 00:00:00.000000000 Z
10
+ date: 2025-02-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: base64
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.6.2
162
+ rubygems_version: 3.6.3
163
163
  specification_version: 4
164
164
  summary: 'NEAR.rb: NEAR for Ruby'
165
165
  test_files: []