near 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d113e40c4ca1414cd8bff319acdaeba7d7cd1a07ebc866ce875afd2080e44b1
4
- data.tar.gz: ae7151a4a1022ecf3b9d652ae11bcabfffc427ccaad0cc07858fd662fb91cbd8
3
+ metadata.gz: aa0995c2a2fec35657f6ce459546a2f3a83b69d306965a301da46a99fb64afc3
4
+ data.tar.gz: 56826739970ee57d1485fd533404523408fc8072f1db2b7cd64f18864e6c99ce
5
5
  SHA512:
6
- metadata.gz: 779325138cf044d38991e1911d8bf115f8559d86a530bda11e0b97a75367406386b63e81a7e9a3d9db69b70ab826ce146e0b326efdb9e69dcf3545083227c1bb
7
- data.tar.gz: f5b55100bc19a9c8d3e6c165e66d7780b94a60ed1fea90bce0523cf77657b384b13c1439c8aabbc4db2b6d2ae5534ef186ad9d7ed82dd2bb3e85ee915f5e1fb0
6
+ metadata.gz: dfa74fb61db51e15c37af7c9b95c2b0d5ae15595f59bdce9b1198ed866eec9a2c7bc739b2149e0217593ee340af72af78e674fd7891b2b825f487f66bf979985
7
+ data.tar.gz: dfce931afa3709136c6f1f5bf42d9d1bdbf180af3e1d172d179c702b6614678cfae746829f3a3fb698c59d26c2bec17e5aa37169deb05f89e55312dbac86dab9
data/CHANGES.md CHANGED
@@ -5,32 +5,35 @@ 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.2 - 2025-05-12
9
+ ### Changed
10
+ - Enhance `call_function` and `deploy_contract`
11
+ ### Added
12
+ - Define `NEAR::Transaction::MAX_SIZE`
13
+ ### Fixed
14
+ - Fix detection of printable strings
15
+
8
16
  ## 0.3.1 - 2025-02-05
9
17
 
10
18
  ## 0.3.0 - 2025-02-02
11
-
12
19
  ### Added
13
20
  - Implement block data accessors
14
21
  - Implement transaction data accessors
15
22
  - Implement action parsing
16
-
17
23
  ### Changed
18
24
  - Adopt Faraday as the HTTP client
19
25
  - Improve HTTP error handling and retries
20
26
 
21
27
  ## 0.2.0 - 2025-01-29
22
-
23
28
  ### Added
24
29
  - `Network#fetch(block)`
25
30
  - `NEAR.testnet`, `NEAR.mainnet`
26
-
27
31
  ### Changed
28
32
  - Use the NEAR_CLI environmnet variable, if set
29
33
  - Use a temporary file for `call_function`
30
34
  - Enhance `call_function()`
31
35
  - Enhance `create_account_with_funding()`
32
36
  - Enhance `delete_account()`
33
-
34
37
  ### Fixed
35
38
  - Fix the formatting of balances
36
39
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # NEAR.rb: NEAR for Ruby
2
2
 
3
3
  [![License](https://img.shields.io/badge/license-Public%20Domain-blue.svg)](https://unlicense.org)
4
- [![Compatibility](https://img.shields.io/badge/ruby-3.0%2B-blue)](https://rubygems.org/gems/near)
4
+ [![Compatibility](https://img.shields.io/badge/ruby-3.0%2B-blue)](https://rubyreferences.github.io/rubychanges/3.0.html)
5
5
  [![Package](https://img.shields.io/gem/v/near)](https://rubygems.org/gems/near)
6
6
  [![Documentation](https://img.shields.io/badge/rubydoc-latest-blue)](https://rubydoc.info/gems/near)
7
7
 
@@ -313,12 +313,13 @@ https://rubydoc.info/gems/near
313
313
  git clone https://github.com/dryruby/near.rb.git
314
314
  ```
315
315
 
316
- - - -
316
+ ---
317
317
 
318
- [![Share on Twitter](https://img.shields.io/badge/share%20on-twitter-03A9F4?logo=twitter)](https://x.com/share?url=https://github.com/dryruby/near.rb&text=NEAR.rb)
318
+ [![Share on X](https://img.shields.io/badge/share%20on-x-03A9F4?logo=x)](https://x.com/intent/post?url=https://github.com/dryruby/near.rb&text=NEAR.rb)
319
319
  [![Share on Reddit](https://img.shields.io/badge/share%20on-reddit-red?logo=reddit)](https://reddit.com/submit?url=https://github.com/dryruby/near.rb&title=NEAR.rb)
320
- [![Share on Hacker News](https://img.shields.io/badge/share%20on-hacker%20news-orange?logo=ycombinator)](https://news.ycombinator.com/submitlink?u=https://github.com/dryruby/near.rb&t=NEAR.rb)
321
- [![Share on Facebook](https://img.shields.io/badge/share%20on-facebook-1976D2?logo=facebook)](https://www.facebook.com/sharer/sharer.php?u=https://github.com/dryruby/near.rb)
320
+ [![Share on Hacker News](https://img.shields.io/badge/share%20on-hn-orange?logo=ycombinator)](https://news.ycombinator.com/submitlink?u=https://github.com/dryruby/near.rb&t=NEAR.rb)
321
+ [![Share on Facebook](https://img.shields.io/badge/share%20on-fb-1976D2?logo=facebook)](https://www.facebook.com/sharer/sharer.php?u=https://github.com/dryruby/near.rb)
322
+ [![Share on LinkedIn](https://img.shields.io/badge/share%20on-linkedin-3949AB?logo=linkedin)](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/dryruby/near.rb)
322
323
 
323
324
  [NEAR CLI]: https://github.com/near/near-cli-rs
324
325
  [NEAR Protocol]: https://near.org
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -36,12 +36,12 @@ module NEAR::CLI::Contract
36
36
  # @param [NEAR::Balance] deposit Amount of NEAR to attach
37
37
  # @param [NEAR::Gas, #to_s] gas Amount of gas to attach
38
38
  # @return [String] Transaction result
39
- def call_function(contract, method_name, args = {}, signer:, deposit: nil, gas: '100.0 Tgas')
39
+ def call_function(contract, method_name, args = {}, signer: nil, deposit: nil, gas: '100.0 Tgas')
40
40
  args = case args
41
41
  when Hash, Array then ['json-args', args.to_json]
42
- when String then case
43
- when args.ascii_only? then ['text-args', args]
44
- else ['base64-args', Base64.strict_encode64(args)]
42
+ when String then case args
43
+ when /[^[:print:]]/ then ['base64-args', Base64.strict_encode64(args)]
44
+ else ['text-args', args]
45
45
  end
46
46
  when Pathname then ['file-args', args.to_s]
47
47
  else raise ArgumentError, "Invalid argument type: #{args.inspect}"
@@ -53,7 +53,7 @@ module NEAR::CLI::Contract
53
53
  *args,
54
54
  'prepaid-gas', gas.to_s,
55
55
  'attached-deposit', (deposit ? deposit.to_s : '0') + ' NEAR',
56
- 'sign-as', signer.to_s,
56
+ 'sign-as', (signer || contract).to_s,
57
57
  'network-config', @network,
58
58
  'sign-with-keychain',
59
59
  'send'
@@ -65,34 +65,34 @@ module NEAR::CLI::Contract
65
65
  ##
66
66
  # Deploys a new contract.
67
67
  #
68
- # @param [String] contract_id Account to deploy the contract to
68
+ # @param [NEAR::Account, #to_s] contract Account to deploy the contract to
69
69
  # @param [String] wasm_path Path to the .wasm file
70
- # @param [String] signer_id Account that signs the transaction
71
70
  # @param [String, nil] init_method Method to call after deployment
72
71
  # @param [Hash] init_args Arguments for the init method
73
72
  # @param [String] init_deposit Deposit for the init method
74
73
  # @param [String] init_gas Gas for the init method
75
74
  # @return [String] Transaction result
76
- def deploy_contract(contract_id, wasm_path, signer_id:, init_method: nil, init_args: {},
75
+ def deploy_contract(contract, wasm_path, init_method: nil, init_args: {},
77
76
  init_deposit: '0 NEAR', init_gas: '30 TGas')
78
77
  args = [
79
78
  'contract',
80
79
  'deploy',
81
- contract_id,
80
+ contract.to_s,
82
81
  'use-file', wasm_path
83
82
  ]
84
83
 
85
- if init_method
86
- args += [
84
+ args += if init_method
85
+ [
87
86
  'with-init-call', init_method,
88
87
  'json-args', init_args.to_json,
89
88
  'prepaid-gas', init_gas,
90
89
  'attached-deposit', init_deposit
91
90
  ]
91
+ else
92
+ ['without-init-call']
92
93
  end
93
94
 
94
95
  args += [
95
- 'sign-as', signer_id,
96
96
  'network-config', @network,
97
97
  'sign-with-keychain',
98
98
  'send'
@@ -3,6 +3,12 @@
3
3
  ##
4
4
  # Represents a NEAR transaction.
5
5
  class NEAR::Transaction
6
+ ##
7
+ # The maximum byte size of a NEAR transaction.
8
+ #
9
+ # @see https://github.com/near/nearcore/blob/3a584c2/core/parameters/res/runtime_configs/parameters.snap#L187
10
+ MAX_SIZE = 1_572_864
11
+
6
12
  ##
7
13
  # @param [Hash] json
8
14
  # @return [NEAR::Transaction]
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-05 00:00:00.000000000 Z
10
+ date: 2025-05-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: base64
@@ -85,14 +85,14 @@ dependencies:
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '3.12'
88
+ version: '3.13'
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '3.12'
95
+ version: '3.13'
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: yard
98
98
  requirement: !ruby/object:Gem::Requirement