adequate_crypto_address 0.1.6 → 0.1.7

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: 157a8f6e3a9872cb7fb5f4dba759e27031c87753b2f7c44b2736f8a58a97e01f
4
- data.tar.gz: 50220278e3436aee8f4aad3fcf931008f1b4bd99e6ff686ca10bc926c0b3a761
3
+ metadata.gz: 317e610de2701baca977b7cb48ea5fa4b76d97935df0f932a2d3c1bdba4d3910
4
+ data.tar.gz: 8f8c8f1fa6eaa3bdb4df6e4dca49dd83f0bb1c6a6096cefcdb16bc8c10c91f3c
5
5
  SHA512:
6
- metadata.gz: fb2dae9e2f9821e038103dab4508a512be41cf4df2ac5d395fd29243eeac20e0919de2c3d9a03fed52327a88ad3c39c8982d699adbe57bcd519dbb8e36b34879
7
- data.tar.gz: 4b19f994077c005e1e097f3ad62530e2ef2c253cf21e98a4ddea56a53f8deaafcda6be1ab495e0cf1ea028e8eb3e9878d175c3bd92c01e69050be28ffc784c63
6
+ metadata.gz: 971aa5e40bdda01d44da458389afb144df70b4109ed199e5b7f81e254a603fcbe09c10dc48636b5d458c921c05297838e4aeb8bd994f6d3bb61d883bb7862f22
7
+ data.tar.gz: e280c85592e69cb724cef1fa4c5ca4ebfe409771cade548169355ad6ef45b100406e2fe7f62ab967f844483b326f75cb4be5bec356826513dd325db789e2295b
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.6.gem
6
+ gem push adequate_crypto_address-0.1.7.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.'
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AdequateCryptoAddress
4
+ class Monero
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
+ end
@@ -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.6'
4
+ VERSION = '0.1.7'
5
5
  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/monero'
14
16
 
15
17
  module AdequateCryptoAddress
16
18
  class UnknownCurrency < StandardError; end
@@ -178,6 +178,27 @@ 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', :monero)
195
+ expect(described_class).to be_valid('4TZ76dT4mbsizsTtJzy7kYBo9f8xduc8wTsWb86pCmx5Cmh43CDxNS1FRcMrE3CNQ2ZT17vzCudc5TbNYBzizwqZFah5K1Js7VpL88qPSi', :monero)
196
+ end
197
+
198
+ it 'validates wrong addresses' do
199
+ expect(described_class).not_to be_valid('NOT_VALID_4BKnGLZNZ5pjpXCZedGfVQjpXCZedGfVQjp', :monero)
200
+ end
201
+ end
181
202
  end
182
203
 
183
204
  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.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - vtm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-30 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base58
@@ -68,7 +68,6 @@ dependencies:
68
68
  version: '3.10'
69
69
  description: A Ruby Library for dealing with validation cryptocurrency adresses.
70
70
  email:
71
- - vtmilyakov@yandex.ru
72
71
  executables: []
73
72
  extensions: []
74
73
  extra_rdoc_files: []
@@ -92,6 +91,8 @@ files:
92
91
  - lib/adequate_crypto_address/dash.rb
93
92
  - lib/adequate_crypto_address/eth.rb
94
93
  - lib/adequate_crypto_address/ltc.rb
94
+ - lib/adequate_crypto_address/monero.rb
95
+ - lib/adequate_crypto_address/ton.rb
95
96
  - lib/adequate_crypto_address/utils/bch.rb
96
97
  - lib/adequate_crypto_address/utils/bech32.rb
97
98
  - lib/adequate_crypto_address/version.rb