near_api 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +27 -0
- data/README.md +1 -0
- data/lib/near_api/base58.rb +13 -6
- data/lib/near_api/version.rb +1 -1
- data/near_api.gemspec +3 -3
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45334f18df28991a38a1e2301b797334ccf9ac72156d0667bfaee2ce16175b86
|
4
|
+
data.tar.gz: 3dd56b817520c32493de57a2510ea76e1d2de7563ad5670b38fde97903b060f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f948aa2cb4e9a55993192a273a580a0a987cc13c6c2a2b613bef361e7ac5a604d5ce644ccf9c1312dafcdedca68e521877f31306530a51fb00ea1b0c15aa363
|
7
|
+
data.tar.gz: f80f23346467ed75fe3f66bf4a108ae54070f9072f0d786a89e1df6e9402a8995e36f2431107a299fcb0e99f0020160734799bf4c8138c0b4b3aebb517d4439c
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: rspec
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
concurrency:
|
16
|
+
group: ${{ github.ref }}
|
17
|
+
cancel-in-progress: true
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: 3.0.2
|
24
|
+
- name: Install dependencies
|
25
|
+
run: bundle install --path vendor/bundle --jobs 4 --retry 3
|
26
|
+
- name: Rspec
|
27
|
+
run: bundle exec rspec
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
![tests](https://github.com/near-rails-guide/near_api/actions/workflows/ci.yml/badge.svg)
|
1
2
|
# NearApi
|
2
3
|
|
3
4
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/near_api`. To experiment with that code, run `bin/console` for an interactive prompt.
|
data/lib/near_api/base58.rb
CHANGED
@@ -4,18 +4,22 @@ class NearApi::Base58
|
|
4
4
|
BASE = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
5
5
|
|
6
6
|
def self.encode(bytestring)
|
7
|
-
number = bytestring.unpack(
|
8
|
-
sum + byte * (256
|
7
|
+
number = bytestring.unpack('C*').reverse.each_with_index.inject(0) do |sum, (byte, index)|
|
8
|
+
sum + byte * (256**index)
|
9
9
|
end
|
10
|
-
|
10
|
+
nzeroes = bytestring.bytes.find_index { |b| b != 0 } || bytestring.length - 1
|
11
|
+
prefix = BASE[0] * nzeroes
|
12
|
+
prefix + tos(number)
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.decode(encoded_string)
|
14
16
|
integer = toi encoded_string
|
15
|
-
|
17
|
+
nzeroes = encoded_string.chars.find_index { |c| c != BASE[0] } || encoded_string.length - 1
|
18
|
+
prefix = nzeroes < 0 ? '' : 0.chr * nzeroes
|
19
|
+
prefix + to_bytestring(integer)
|
16
20
|
end
|
17
21
|
|
18
|
-
def self.toi(string=to_s, base=58, digits=BASE)
|
22
|
+
def self.toi(string = to_s, base = 58, digits = BASE)
|
19
23
|
return nil if string.empty?
|
20
24
|
|
21
25
|
integer = 0
|
@@ -26,9 +30,10 @@ class NearApi::Base58
|
|
26
30
|
integer
|
27
31
|
end
|
28
32
|
|
29
|
-
def self.tos(integer=to_i, base=58, digits=BASE)
|
33
|
+
def self.tos(integer = to_i, base = 58, digits = BASE)
|
30
34
|
return '' if integer.nil?
|
31
35
|
return digits[0] if integer == 0
|
36
|
+
|
32
37
|
string = ''
|
33
38
|
while integer > 0
|
34
39
|
integer, index = integer.divmod(base)
|
@@ -38,6 +43,8 @@ class NearApi::Base58
|
|
38
43
|
end
|
39
44
|
|
40
45
|
def self.to_bytestring(number)
|
46
|
+
return 0.chr if number == 0
|
47
|
+
|
41
48
|
integer = number
|
42
49
|
result = ''
|
43
50
|
while integer > 0
|
data/lib/near_api/version.rb
CHANGED
data/near_api.gemspec
CHANGED
@@ -9,13 +9,13 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["700@2rba.com"]
|
10
10
|
|
11
11
|
spec.summary = "NEAR blockchain ruby API"
|
12
|
-
spec.homepage = "https://github.com/
|
12
|
+
spec.homepage = "https://github.com/near-rails-guide/near_api"
|
13
13
|
spec.license = "MIT"
|
14
14
|
spec.required_ruby_version = ">= 2.4.0"
|
15
15
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
-
spec.metadata["source_code_uri"] = "https://github.com/
|
18
|
-
spec.metadata["changelog_uri"] = "https://github.com/
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/near-rails-guide/near_api"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/near-rails-guide/near_api"
|
19
19
|
|
20
20
|
# Specify which files should be added to the gem when it is released.
|
21
21
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serg Tyatin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: borsh-rb
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".github/workflows/ci.yml"
|
76
77
|
- ".gitignore"
|
77
78
|
- ".rspec"
|
78
79
|
- Gemfile
|
@@ -92,13 +93,13 @@ files:
|
|
92
93
|
- lib/near_api/status.rb
|
93
94
|
- lib/near_api/version.rb
|
94
95
|
- near_api.gemspec
|
95
|
-
homepage: https://github.com/
|
96
|
+
homepage: https://github.com/near-rails-guide/near_api
|
96
97
|
licenses:
|
97
98
|
- MIT
|
98
99
|
metadata:
|
99
|
-
homepage_uri: https://github.com/
|
100
|
-
source_code_uri: https://github.com/
|
101
|
-
changelog_uri: https://github.com/
|
100
|
+
homepage_uri: https://github.com/near-rails-guide/near_api
|
101
|
+
source_code_uri: https://github.com/near-rails-guide/near_api
|
102
|
+
changelog_uri: https://github.com/near-rails-guide/near_api
|
102
103
|
post_install_message:
|
103
104
|
rdoc_options: []
|
104
105
|
require_paths:
|
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
115
|
- !ruby/object:Gem::Version
|
115
116
|
version: '0'
|
116
117
|
requirements: []
|
117
|
-
rubygems_version: 3.2.
|
118
|
+
rubygems_version: 3.2.32
|
118
119
|
signing_key:
|
119
120
|
specification_version: 4
|
120
121
|
summary: NEAR blockchain ruby API
|