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 +4 -4
- data/README.md +5 -0
- data/lib/glueby/active_record/system_information.rb +69 -0
- data/lib/glueby/configuration.rb +1 -1
- data/lib/glueby/contract/errors.rb +12 -10
- data/lib/glueby/fee_provider.rb +2 -2
- data/lib/glueby/internal/wallet/errors.rb +6 -6
- data/lib/glueby/version.rb +1 -1
- data/lib/glueby.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cae8a0e06be77affdb1895724a26137b5fde2bab8cc27fb73d9aa45f2c351c5
|
4
|
+
data.tar.gz: 2cc677f69e1cc1ad3e6468662e476b4bd5082b0e765f15f44b6b63426b2663f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/glueby/configuration.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
module Glueby
|
2
2
|
module Contract
|
3
3
|
module Errors
|
4
|
-
class InsufficientFunds <
|
5
|
-
class InsufficientTokens <
|
6
|
-
class
|
7
|
-
|
8
|
-
|
9
|
-
class
|
10
|
-
class
|
11
|
-
class
|
12
|
-
class
|
13
|
-
class
|
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
|
data/lib/glueby/fee_provider.rb
CHANGED
@@ -3,7 +3,7 @@ module Glueby
|
|
3
3
|
|
4
4
|
autoload :Tasks, 'glueby/fee_provider/tasks'
|
5
5
|
|
6
|
-
class NoUtxosInUtxoPool <
|
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 <
|
6
|
-
class WalletUnloaded <
|
7
|
-
class WalletAlreadyLoaded <
|
8
|
-
class WalletAlreadyCreated <
|
9
|
-
class WalletNotFound <
|
10
|
-
class InvalidSighashType <
|
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
|
data/lib/glueby/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tapyrus
|