coin-address-validators 0.0.6 → 0.0.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 +4 -4
- data/Gemfile.lock +12 -8
- data/lib/coin-address-validators.rb +5 -1
- data/lib/coin-address-validators/version.rb +1 -1
- data/spec/lib/coin-address-validators_spec.rb +22 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f486fb3131fa155643d7b9bf39c6ce2db470857
|
4
|
+
data.tar.gz: e24a7af91463bcd2db77b8bec484914f5a0bc4a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 594680e8d565e45bc28c0d01cf1bc91f238bb2ed39c06bb8d80b92b25c7ab0dda65fda056c26b4dc5373df1d354dfcde10d142be2d8f069119abc794bbf9e685
|
7
|
+
data.tar.gz: 6109a8e65ac11ab77514367076121c82b9da8f0ee6af50a7ef28e546ebee526c95e4015154f5d7a564f9f51d3504684650e1a6d5c734c6090936ecfd80a87c2b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
coin-address-validators (0.0.
|
4
|
+
coin-address-validators (0.0.7)
|
5
5
|
base_x
|
6
6
|
bitcoin-ruby
|
7
7
|
cashaddress
|
@@ -11,24 +11,28 @@ GEM
|
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
13
|
base_x (0.8.1)
|
14
|
-
bitcoin-ruby (0.0.
|
14
|
+
bitcoin-ruby (0.0.19)
|
15
|
+
eventmachine
|
16
|
+
ffi
|
17
|
+
scrypt
|
15
18
|
byebug (9.0.6)
|
16
19
|
cashaddress (0.1.0)
|
17
20
|
diff-lcs (1.3)
|
18
21
|
digest-sha3 (1.1.0)
|
19
|
-
eth (0.4.
|
22
|
+
eth (0.4.10)
|
20
23
|
digest-sha3 (~> 1.1)
|
21
24
|
ffi (~> 1.0)
|
22
25
|
money-tree (~> 0.10.0)
|
23
26
|
rlp (~> 0.7.3)
|
24
|
-
scrypt (~> 3.0.
|
25
|
-
|
27
|
+
scrypt (~> 3.0.6)
|
28
|
+
eventmachine (1.2.7)
|
29
|
+
ffi (1.11.1)
|
26
30
|
ffi-compiler (1.0.1)
|
27
31
|
ffi (>= 1.0.0)
|
28
32
|
rake
|
29
33
|
money-tree (0.10.0)
|
30
34
|
ffi
|
31
|
-
rake (12.3.
|
35
|
+
rake (12.3.2)
|
32
36
|
rlp (0.7.3)
|
33
37
|
rspec (3.7.0)
|
34
38
|
rspec-core (~> 3.7.0)
|
@@ -43,7 +47,7 @@ GEM
|
|
43
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
48
|
rspec-support (~> 3.7.0)
|
45
49
|
rspec-support (3.7.1)
|
46
|
-
scrypt (3.0.
|
50
|
+
scrypt (3.0.6)
|
47
51
|
ffi-compiler (>= 1.0, < 2.0)
|
48
52
|
|
49
53
|
PLATFORMS
|
@@ -56,4 +60,4 @@ DEPENDENCIES
|
|
56
60
|
rspec
|
57
61
|
|
58
62
|
BUNDLED WITH
|
59
|
-
1.
|
63
|
+
1.17.2
|
@@ -4,7 +4,7 @@ require 'cashaddress'
|
|
4
4
|
require 'eth'
|
5
5
|
|
6
6
|
class CoinAddressValidators
|
7
|
-
TOKENS = %w[ret]
|
7
|
+
TOKENS = %w[ret erct]
|
8
8
|
require 'coin-address-validators/version'
|
9
9
|
|
10
10
|
attr_reader :coin
|
@@ -18,6 +18,10 @@ class CoinAddressValidators
|
|
18
18
|
inner_validator.valid?(address)
|
19
19
|
end
|
20
20
|
|
21
|
+
def parse_cash_addr(address)
|
22
|
+
inner_validator.parse_cash_addr(address)
|
23
|
+
end
|
24
|
+
|
21
25
|
def self.[](coin)
|
22
26
|
@singletons ||= {}
|
23
27
|
@singletons[coin] ||= new(coin)
|
@@ -40,6 +40,13 @@ RSpec.describe CoinAddressValidators do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
context "erct token" do
|
44
|
+
it "returns correctly" do
|
45
|
+
expect(CoinAddressValidators["erct"].valid?("0xff0a8531f38e5f143a0444d066fad0a0f0833853")).to be_truthy
|
46
|
+
expect(CoinAddressValidators["erct"].valid?("0xff0a8531f38e5f143a0444d066fad0a0f08338534")).to be_falsey
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
43
50
|
context "ltc" do
|
44
51
|
it "returns correctly" do
|
45
52
|
expect(CoinAddressValidators["ltc"].valid?("LajyQBeZaBA1NkZDeY8YT5RYYVRkXMvb2T")).to be_truthy
|
@@ -65,8 +72,19 @@ RSpec.describe CoinAddressValidators do
|
|
65
72
|
end
|
66
73
|
end
|
67
74
|
|
68
|
-
describe "
|
69
|
-
|
75
|
+
describe "#parse_cash_addr" do
|
76
|
+
|
77
|
+
%w[btc eth ltc xrp erct usdt].each do |coin|
|
78
|
+
context "#{coin}Validator" do
|
79
|
+
it "raise error" do
|
80
|
+
expect do
|
81
|
+
CoinAddressValidators[coin].parse_cash_addr("ABC")
|
82
|
+
end.to raise_error(NoMethodError)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "BchValidator" do
|
70
88
|
context "invalid address" do
|
71
89
|
it "handles gracefully" do
|
72
90
|
legacy_address, ok = CoinAddressValidators["bch"].parse_cash_addr("ABC")
|
@@ -74,5 +92,7 @@ RSpec.describe CoinAddressValidators do
|
|
74
92
|
end
|
75
93
|
end
|
76
94
|
end
|
95
|
+
|
77
96
|
end
|
97
|
+
|
78
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coin-address-validators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phuong Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bitcoin-ruby
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.6.14
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Validators for btc, bch, ltc, eth, xrp addresses
|