adequate_crypto_address 0.1.5 → 0.1.8

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: cc397b65e7cbd255bfcc82527b49a87832cfb2385fd4c2dca2ba7c170e33d8d8
4
- data.tar.gz: b7265ddb5d2fe06075f2ae53cd4ad50c269022387fcfd3715299ba66ba102d66
3
+ metadata.gz: 454d13bbd68af39b638c32a2ec39e2b0d94f71a0c5479cb01a3f0f00fd89abe0
4
+ data.tar.gz: 0b6fc0a2ea85706723f8242514d5703a62720be74ab9e0d8379b61f17b4f369f
5
5
  SHA512:
6
- metadata.gz: 7ebe1f23778e6af6cca6eb829be82c3351888588957986a35f1dda48c6a5d6cc5ec2a903d063adb7d397759ca519d7e50e7b448718de92c73ea5cafac897c711
7
- data.tar.gz: 5ad32e4058dea93f5fe50c531fd4f5ace5b1a1f5549d60552dcfb0494d706bcaec58ca30ad6fe0e80e56be686bee9decfd4d9228c32763a44b2cfd31af4cd918
6
+ metadata.gz: 8b82dd552389025f66a26671515b43974ec9dbd442f7556c8e179fac8c0743f059ce0bd1a9706d750821dc7a151e91e6286c489f69cdb3a9c7bae20532937cd0
7
+ data.tar.gz: f5ff8a4f9c8de4da94f28247c8f9a24ddbbdf1294e064c98056e96a84b7b2dce11e123830b02be08a271c36bd4f280ca1d8486b11c70f2346d84781e3eefad73
data/Makefile CHANGED
@@ -3,4 +3,4 @@ build:
3
3
  gem build adequate_crypto_address.gemspec
4
4
 
5
5
  push:
6
- gem push adequate_crypto_address-0.1.5.gem
6
+ gem push adequate_crypto_address-0.1.8.gem
data/README.md CHANGED
@@ -48,6 +48,8 @@ gem install adequate_crypto_address
48
48
  * Zcash/ZEC, `'zcash'` or `'ZEC'` types: `:prod :test`
49
49
  * Ethereum/ETH, `'ethereum'` or `'ETH'`
50
50
  * Ripple/XRP, `'ripple'` or `'XRP'`
51
+ * Toncoin, `'TON'`
52
+ * Monero/XRM, `'monero'`
51
53
 
52
54
  ## Usage
53
55
 
@@ -8,7 +8,6 @@ Gem::Specification.new do |spec|
8
8
  spec.name = 'adequate_crypto_address'
9
9
  spec.version = AdequateCryptoAddress::VERSION
10
10
  spec.authors = ['vtm']
11
- spec.email = ['vtmilyakov@yandex.ru']
12
11
 
13
12
  spec.summary = 'A Ruby Library for dealing with validation cryptocurrency adresses.'
14
13
  spec.description = 'A Ruby Library for dealing with validation cryptocurrency adresses.'
@@ -18,9 +17,8 @@ Gem::Specification.new do |spec|
18
17
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
18
  spec.require_paths = ['lib']
20
19
 
21
- spec.add_dependency 'base58', '~> 0.2.3'
22
- spec.add_dependency 'digest-sha3', '~> 1.1.0'
23
- spec.add_development_dependency 'bundler', '~> 1.16'
24
- spec.add_development_dependency 'rake', '~> 10.0'
25
- spec.add_development_dependency 'rspec', '~> 3.0'
20
+ spec.add_dependency 'base58', '~> 0.2'
21
+ spec.add_dependency 'keccak', '~> 1.3'
22
+ spec.add_development_dependency 'rake', '~> 13.0'
23
+ spec.add_development_dependency 'rspec', '~> 3.10'
26
24
  end
@@ -76,7 +76,7 @@ module AdequateCryptoAddress
76
76
  end
77
77
 
78
78
  def keccak256(x)
79
- Digest::SHA3.new(256).digest(x)
79
+ Digest::Keccak.new(256).digest(x)
80
80
  end
81
81
  end
82
82
  Ethereum = Eth
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AdequateCryptoAddress
4
+ class Ton
5
+ attr_reader :address, :type
6
+
7
+ def initialize(address)
8
+ @address = address
9
+ @type = address_type
10
+ end
11
+
12
+ def valid?(type = nil)
13
+ if type
14
+ address_type == type.to_sym
15
+ else
16
+ !address_type.nil?
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def address_type
23
+ return :TON if address.size == 48 && pattern_valid?
24
+ end
25
+
26
+ def pattern_valid?
27
+ address.match(/([0-9a-zA-Z]|-|_){48}/)
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdequateCryptoAddress
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.8'
5
5
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AdequateCryptoAddress
4
+ class Xmr
5
+ attr_reader :address, :type
6
+
7
+ def initialize(address)
8
+ @address = address
9
+ @type = address_type
10
+ end
11
+
12
+ def valid?(type = nil)
13
+ if type
14
+ address_type == type.to_sym
15
+ else
16
+ !address_type.nil?
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def address_type
23
+ return nil unless [95, 106].include?(address.size)
24
+
25
+ return :monero if pattern_valid?
26
+ end
27
+
28
+ def pattern_valid?
29
+ address.size == 95 ?
30
+ address.match(/^4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}$/) :
31
+ address.match(/^4[1-9A-HJ-NP-Za-km-z]{105}(?:[1-9A-HJ-NP-Za-km-z]{30})?$/)
32
+ end
33
+ end
34
+ Monero = Xmr
35
+ end
@@ -11,6 +11,8 @@ require 'adequate_crypto_address/xrp'
11
11
  require 'adequate_crypto_address/dash'
12
12
  require 'adequate_crypto_address/zec'
13
13
  require 'adequate_crypto_address/ltc'
14
+ require 'adequate_crypto_address/ton'
15
+ require 'adequate_crypto_address/xmr'
14
16
 
15
17
  module AdequateCryptoAddress
16
18
  class UnknownCurrency < StandardError; end
@@ -178,6 +178,36 @@ RSpec.describe(AdequateCryptoAddress) do
178
178
  expect(described_class).not_to be_valid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', :zcash, :test)
179
179
  end
180
180
  end
181
+
182
+ context 'Toncoin' do
183
+ it 'validates addresses' do
184
+ expect(described_class).to be_valid('UQCScs4HjjwnlIFKIq_juiuLLLnjJKTjQyfcADjYNvdYwn-l', :TON)
185
+ end
186
+
187
+ it 'validates wrong addresses' do
188
+ expect(described_class).not_to be_valid('wrongFKIq_juiuLLLnjJKTjQyfcAD', :TON)
189
+ end
190
+ end
191
+
192
+ context 'Monero' do
193
+ it 'validates addresses' do
194
+ expect(described_class).to be_valid('4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQVmzCh57', :XMR)
195
+ expect(described_class).to be_valid('4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQVmzCh57', :monero)
196
+ expect(described_class).to be_valid('4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQVmzCh57', :Xmr)
197
+ expect(described_class).to be_valid('4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQjpXCZedGfVQVmzCh57', :xmr)
198
+ expect(described_class).to be_valid('4TZ76dT4mbsizsTtJzy7kYBo9f8xduc8wTsWb86pCmx5Cmh43CDxNS1FRcMrE3CNQ2ZT17vzCudc5TbNYBzizwqZFah5K1Js7VpL88qPSi', :monero)
199
+ expect(described_class).to be_valid('4TZ76dT4mbsizsTtJzy7kYBo9f8xduc8wTsWb86pCmx5Cmh43CDxNS1FRcMrE3CNQ2ZT17vzCudc5TbNYBzizwqZFah5K1Js7VpL88qPSi', :Xmr)
200
+ expect(described_class).to be_valid('4TZ76dT4mbsizsTtJzy7kYBo9f8xduc8wTsWb86pCmx5Cmh43CDxNS1FRcMrE3CNQ2ZT17vzCudc5TbNYBzizwqZFah5K1Js7VpL88qPSi', :Xmr)
201
+ expect(described_class).to be_valid('4TZ76dT4mbsizsTtJzy7kYBo9f8xduc8wTsWb86pCmx5Cmh43CDxNS1FRcMrE3CNQ2ZT17vzCudc5TbNYBzizwqZFah5K1Js7VpL88qPSi', :xmr)
202
+ end
203
+
204
+ it 'validates wrong addresses' do
205
+ expect(described_class).not_to be_valid('NOT_VALID_4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjp', :monero)
206
+ expect(described_class).not_to be_valid('NOT_VALID_4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjp', :Xmr)
207
+ expect(described_class).not_to be_valid('NOT_VALID_4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjp', :XMR)
208
+ expect(described_class).not_to be_valid('NOT_VALID_4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjp', :xmr)
209
+ end
210
+ end
181
211
  end
182
212
 
183
213
  describe '.address' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adequate_crypto_address
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - vtm
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-13 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base58
@@ -16,73 +16,58 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.3
19
+ version: '0.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.3
26
+ version: '0.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: digest-sha3
28
+ name: keccak
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.0
33
+ version: '1.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.0
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.16'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.16'
40
+ version: '1.3'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '10.0'
47
+ version: '13.0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '10.0'
54
+ version: '13.0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rspec
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '3.0'
61
+ version: '3.10'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '3.0'
68
+ version: '3.10'
83
69
  description: A Ruby Library for dealing with validation cryptocurrency adresses.
84
70
  email:
85
- - vtmilyakov@yandex.ru
86
71
  executables: []
87
72
  extensions: []
88
73
  extra_rdoc_files: []
@@ -106,9 +91,11 @@ files:
106
91
  - lib/adequate_crypto_address/dash.rb
107
92
  - lib/adequate_crypto_address/eth.rb
108
93
  - lib/adequate_crypto_address/ltc.rb
94
+ - lib/adequate_crypto_address/ton.rb
109
95
  - lib/adequate_crypto_address/utils/bch.rb
110
96
  - lib/adequate_crypto_address/utils/bech32.rb
111
97
  - lib/adequate_crypto_address/version.rb
98
+ - lib/adequate_crypto_address/xmr.rb
112
99
  - lib/adequate_crypto_address/xrp.rb
113
100
  - lib/adequate_crypto_address/zec.rb
114
101
  - spec/adequate_crypto_address/bch_spec.rb
@@ -118,7 +105,7 @@ homepage: https://github.com/vtm9/adequate_crypto_address
118
105
  licenses:
119
106
  - MIT
120
107
  metadata: {}
121
- post_install_message:
108
+ post_install_message:
122
109
  rdoc_options: []
123
110
  require_paths:
124
111
  - lib
@@ -133,8 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
120
  - !ruby/object:Gem::Version
134
121
  version: '0'
135
122
  requirements: []
136
- rubygems_version: 3.0.3
137
- signing_key:
123
+ rubygems_version: 3.2.22
124
+ signing_key:
138
125
  specification_version: 4
139
126
  summary: A Ruby Library for dealing with validation cryptocurrency adresses.
140
127
  test_files: []