glueby 0.8.1 → 0.9.0

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: '0196e03513c71e992b7b126c3100a6a57bff96210479f97736a7ea1893f029ec'
4
- data.tar.gz: f2d3fa7ec7918394054447ccbca4dff5f039a0a8ef5d431311800dcae9fdb2e6
3
+ metadata.gz: 5cae8a0e06be77affdb1895724a26137b5fde2bab8cc27fb73d9aa45f2c351c5
4
+ data.tar.gz: 2cc677f69e1cc1ad3e6468662e476b4bd5082b0e765f15f44b6b63426b2663f9
5
5
  SHA512:
6
- metadata.gz: 9bdb76d2162a482823107ac0a61d81436599a3ce49d706c69366ac288c394546fa553e896c91a9af084a3f3991d698307a3cfcfc457b47625cef06e3f5b6c113
7
- data.tar.gz: e1f8f4885822bc70475e99856858421e693db63b3dae96abaaac2c235d7c2fcd8ca610333a085b03a706976ffdcfffa0c4e5f9ef9f0da8e391a73ee350e93ec4
6
+ metadata.gz: 3e0a80b28635f37a37b4d37eac3fc3bc697bfb3ce580a8c481c60e40fe7776bfcfcb24720d33771e5d73d19c745d03afbee7b380dedd3d0ec51b7258bbb9363b
7
+ data.tar.gz: fd3d0edae5b99212cea7e4a710dd8f52173e1b707617beb881e7f9715afac575e76d5abc18b291f7defa62c7acb4c4e5772163a0953126a2f3fcfeb6a72aa953
data/README.md CHANGED
@@ -457,6 +457,11 @@ Glueby.configure do |config|
457
457
  end
458
458
  ```
459
459
 
460
+ ## Error handling
461
+
462
+ Glueby has base error classes like `Glueby::Error` and `Glueby::ArgumentError`.
463
+ `Glueby::Error` is the base class for the all errors that are raises in the glueby.
464
+ `Glueby::ArgumentError` is the error class for argument errors in public contracts. This notifies the arguments is something wrong to glueby library user-side.
460
465
 
461
466
  ## Development
462
467
 
@@ -12,22 +12,91 @@ module Glueby
12
12
  find_by(info_key: "use_only_finalized_utxo")&.int_value != 0
13
13
  end
14
14
 
15
+
16
+ # Set use_only_finalized_utxo
17
+ # @param [Boolean] status status of whether to use only finalized utxo
18
+ def self.set_use_only_finalized_utxo(status)
19
+ current = find_by(info_key: "use_only_finalized_utxo")
20
+ if current
21
+ current.update!(info_value: boolean_to_string(status))
22
+ else
23
+ create!(
24
+ info_key: "use_only_finalized_utxo",
25
+ info_value: boolean_to_string(status)
26
+ )
27
+ end
28
+ end
29
+
15
30
  # Return default value of the utxo provider
16
31
  # @return [Integer] default value of utxo provider
17
32
  def self.utxo_provider_default_value
18
33
  find_by(info_key: "utxo_provider_default_value")&.int_value
19
34
  end
20
35
 
36
+ # Set utxo_provider_default_value
37
+ # @param [Integer] value default value for utxo provider
38
+ def self.set_utxo_provider_default_value(value)
39
+ current = find_by(info_key: "utxo_provider_default_value")
40
+ if current
41
+ current.update!(info_value: value)
42
+ else
43
+ create!(
44
+ info_key: "utxo_provider_default_value",
45
+ info_value: value
46
+ )
47
+ end
48
+ end
49
+
21
50
  # Return pool size of the utxo provider
22
51
  # @return [Integer] pool size of utxo provider
23
52
  def self.utxo_provider_pool_size
24
53
  find_by(info_key: "utxo_provider_pool_size")&.int_value
25
54
  end
26
55
 
56
+ # Set utxo_provider_pool_size
57
+ # @param [Integer] size pool size of the utxo provider
58
+ def self.set_utxo_provider_pool_size(size)
59
+ current = find_by(info_key: "utxo_provider_pool_size")
60
+ if current
61
+ current.update!(info_value: size)
62
+ else
63
+ create!(
64
+ info_key: "utxo_provider_pool_size",
65
+ info_value: size
66
+ )
67
+ end
68
+ end
69
+
70
+ # If return timestamp is to be executed immediately
71
+ # @return [Boolean] true status of broadcast_on_background
72
+ def self.broadcast_on_background?
73
+ find_by(info_key: "broadcast_on_background")&.int_value != 0
74
+ end
75
+
76
+ # Set the status of broadcast_on_background
77
+ # @param [Boolean] status status of broadcast_on_background
78
+ def self.set_broadcast_on_background(status)
79
+ current = find_by(info_key: "broadcast_on_background")
80
+ if current
81
+ current.update!(info_value: boolean_to_string(status))
82
+ else
83
+ create!(
84
+ info_key: "broadcast_on_background",
85
+ info_value: boolean_to_string(status)
86
+ )
87
+ end
88
+ end
89
+
27
90
  def int_value
28
91
  info_value.to_i
29
92
  end
30
93
 
94
+ private
95
+
96
+ def self.boolean_to_string(status)
97
+ status ? "1" : "0"
98
+ end
99
+
31
100
  end
32
101
  end
33
102
  end
@@ -15,7 +15,7 @@ module Glueby
15
15
  alias_method :use_utxo_provider?, :use_utxo_provider
16
16
 
17
17
  module Errors
18
- class InvalidConfiguration < StandardError; end
18
+ class InvalidConfiguration < Error; end
19
19
  end
20
20
 
21
21
  def initialize
@@ -1,16 +1,18 @@
1
1
  module Glueby
2
2
  module Contract
3
3
  module Errors
4
- class InsufficientFunds < StandardError; end
5
- class InsufficientTokens < StandardError; end
6
- class InvalidAmount < StandardError; end
7
- class InvalidSplit < StandardError; end
8
- class InvalidTokenType < StandardError; end
9
- class InvalidTimestampType < StandardError; end
10
- class TxAlreadyBroadcasted < StandardError; end
11
- class UnsupportedTokenType < StandardError; end
12
- class UnknownScriptPubkey < StandardError; end
13
- class UnsupportedDigestType < StandardError; end
4
+ class InsufficientFunds < Error; end
5
+ class InsufficientTokens < Error; end
6
+ class TxAlreadyBroadcasted < Error; end
7
+
8
+ # Argument Errors
9
+ class InvalidAmount < ArgumentError; end
10
+ class InvalidSplit < ArgumentError; end
11
+ class InvalidTokenType < ArgumentError; end
12
+ class InvalidTimestampType < ArgumentError; end
13
+ class UnsupportedTokenType < ArgumentError; end
14
+ class UnknownScriptPubkey < ArgumentError; end
15
+ class UnsupportedDigestType < ArgumentError; end
14
16
  end
15
17
  end
16
18
  end
@@ -3,7 +3,7 @@ module Glueby
3
3
 
4
4
  autoload :Tasks, 'glueby/fee_provider/tasks'
5
5
 
6
- class NoUtxosInUtxoPool < StandardError; end
6
+ class NoUtxosInUtxoPool < Error; end
7
7
 
8
8
  WALLET_ID = 'FEE_PROVIDER_WALLET'
9
9
  DEFAULT_FIXED_FEE = 1000
@@ -42,7 +42,7 @@ module Glueby
42
42
  # Provide an input for fee to the tx.
43
43
  # @param [Tapyrus::Tx] tx - The tx that is provided fee as a input. It should be signed with ANYONECANPAY flag.
44
44
  # @return [Tapyrus::Tx]
45
- # @raise [ArgumentError] If the signatures that the tx inputs has don't have ANYONECANPAY flag.
45
+ # @raise [Glueby::ArgumentError] If the signatures that the tx inputs has don't have ANYONECANPAY flag.
46
46
  # @raise [Glueby::FeeProvider::NoUtxosInUtxoPool] If there are no UTXOs for paying fee in FeeProvider's UTXO pool
47
47
  def provide(tx)
48
48
  tx.inputs.each do |txin|
@@ -2,12 +2,12 @@ module Glueby
2
2
  module Internal
3
3
  class Wallet
4
4
  module Errors
5
- class ShouldInitializeWalletAdapter < StandardError; end
6
- class WalletUnloaded < StandardError; end
7
- class WalletAlreadyLoaded < StandardError; end
8
- class WalletAlreadyCreated < StandardError; end
9
- class WalletNotFound < StandardError; end
10
- class InvalidSighashType < StandardError; end
5
+ class ShouldInitializeWalletAdapter < Error; end
6
+ class WalletUnloaded < Error; end
7
+ class WalletAlreadyLoaded < Error; end
8
+ class WalletAlreadyCreated < Error; end
9
+ class WalletNotFound < Error; end
10
+ class InvalidSighashType < Error; end
11
11
  end
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Glueby
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
3
3
  end
data/lib/glueby.rb CHANGED
@@ -48,4 +48,9 @@ module Glueby
48
48
  def self.configure
49
49
  yield configuration if block_given?
50
50
  end
51
+
52
+ # Base error classes. These error classes must be used as a super class in all error classes that is defined and
53
+ # raised in glueby library.
54
+ class Error < StandardError; end
55
+ class ArgumentError < Error; end
51
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glueby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-04 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tapyrus