wallet_validator 0.2.0 → 0.3.0

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: 625e53bd99b16075557b5128435fece20ee05dfa3ae80285a9094032b1ae48a7
4
- data.tar.gz: c32ff56118342fe5a5f2a1bb14d4125ffde8ece700100435d7e215565491e51d
3
+ metadata.gz: 9c77b7cf19f5ed3cfe8ea6355ca3f7907e5803d0ea215838a55d2fca60fbd3f1
4
+ data.tar.gz: b8bc279fa50fa6b24dea8028bbb16d4e0ad6655c7e3b0a36551ef704bfd4b732
5
5
  SHA512:
6
- metadata.gz: 01e6c190d7f29b886bf4bd1f6eafdf7467bd511a5d7fd0a85ad95066dd447a3cf856e20ae899b0c9d1d9ab7e2f477bca1616767a1b03e90b4564a72e0278ed23
7
- data.tar.gz: cac58b015e6d63da27ba8e22a5979f60691b58a8d476918304809b25e5fd424775800166f07606a1a355259bb3b256440d5e1c3c54dfb47fd3dfd085faef7368
6
+ metadata.gz: fa5e7fc8b4243be8be3bb74313635409262ba2cb32e3ed2485b0b3a5f04685bde4fba8c3ed85d7c63aff056acb2db0a6df5c2583f1ce6de11ed1a97193248d98
7
+ data.tar.gz: a439d8234bf091e0f6040b0f2ec31f483021d06abe3c15dac3ec75c5ac9f55095c14549f846f0b77d9e57413a1c26c2fc5503a25835602ed2fb813fba10244e0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wallet_validator (0.1.1)
4
+ wallet_validator (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -20,7 +20,15 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- 第三個參數為 `is_testnet`,預設為 false,也就是預設為主鏈錢包格式檢查
23
+ 可以透過直接啟動設定預設值
24
+
25
+ ```ruby
26
+ WalletValidator.configure do |config|
27
+ config.chain = "testnet"
28
+ end
29
+ ```
30
+
31
+ 或是第三個參數為 `is_testnet`,預設為 false,也就是預設為主鏈錢包格式檢查
24
32
 
25
33
  mainnet
26
34
 
@@ -0,0 +1,25 @@
1
+
2
+
3
+ module WalletValidator
4
+ class Config
5
+ class << self
6
+ # @param [Config] new_instance
7
+ attr_writer :instance
8
+
9
+ # @return [Config]
10
+ def instance
11
+ @instance ||= new
12
+ end
13
+ end
14
+
15
+ attr_accessor :chain
16
+
17
+ def initialize(user_config = {})
18
+ self.chain = user_config[:chain]
19
+ end
20
+
21
+ def valid?
22
+ !self.chain.nil?
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module WalletValidator
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require "pry"
2
+ require "wallet_validator/config"
3
+
2
4
  require "wallet_validator/crypto/bech32"
3
5
  require "wallet_validator/crypto/base32"
4
6
  require "wallet_validator/crypto/base58"
@@ -19,11 +21,14 @@ require "wallet_validator/sol"
19
21
  require "wallet_validator/xem"
20
22
  require "wallet_validator/sda"
21
23
 
24
+
22
25
  module WalletValidator
23
26
  class UnknownCurrency < StandardError; end
24
27
  module_function
25
28
 
26
- def valid?(currency, address, is_testnet = false)
29
+ def valid?(currency, address, is_testnet = nil)
30
+ is_testnet ||= WalletValidator::Config.instance.chain == "testnet"
31
+
27
32
  address(currency, address, is_testnet).valid?
28
33
  end
29
34
 
@@ -32,4 +37,12 @@ module WalletValidator
32
37
  rescue NameError
33
38
  raise UnknownCurrency, "Wrong currency #{currency}"
34
39
  end
40
+
41
+ def configure
42
+ yield config = WalletValidator::Config.instance
43
+ end
44
+
45
+ def configured?
46
+ WalletValidator::Config.instance.valid?
47
+ end
35
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wallet_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nic
@@ -35,6 +35,7 @@ files:
35
35
  - lib/wallet_validator/bchsv.rb
36
36
  - lib/wallet_validator/bnb.rb
37
37
  - lib/wallet_validator/btc.rb
38
+ - lib/wallet_validator/config.rb
38
39
  - lib/wallet_validator/crypto/base32.rb
39
40
  - lib/wallet_validator/crypto/base58.rb
40
41
  - lib/wallet_validator/crypto/bech32.rb