glueby 1.1.2 → 1.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -2
- data/.ruby-version +1 -1
- data/README.md +1 -1
- data/glueby.gemspec +3 -3
- data/lib/generators/glueby/contract/templates/initializer.rb.erb +8 -8
- data/lib/generators/glueby/contract/templates/key_table.rb.erb +16 -16
- data/lib/glueby/block_syncer.rb +97 -97
- data/lib/glueby/contract/active_record/timestamp.rb +0 -3
- data/lib/glueby/contract/payment.rb +10 -15
- data/lib/glueby/contract/timestamp/tx_builder/simple.rb +19 -57
- data/lib/glueby/contract/timestamp/tx_builder/trackable.rb +6 -0
- data/lib/glueby/contract/timestamp/tx_builder/updating_trackable.rb +3 -2
- data/lib/glueby/contract/token.rb +163 -86
- data/lib/glueby/contract/tx_builder.rb +1 -0
- data/lib/glueby/internal/contract_builder.rb +462 -0
- data/lib/glueby/internal/wallet/abstract_wallet_adapter.rb +2 -0
- data/lib/glueby/internal/wallet/active_record/utxo.rb +3 -2
- data/lib/glueby/internal/wallet.rb +149 -12
- data/lib/glueby/internal.rb +1 -0
- data/lib/glueby/utxo_provider/tasks.rb +0 -2
- data/lib/glueby/utxo_provider.rb +15 -34
- data/lib/glueby/version.rb +1 -1
- data/lib/tasks/glueby/contract/timestamp.rake +0 -1
- metadata +14 -13
data/lib/glueby/utxo_provider.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Glueby
|
2
2
|
class UtxoProvider
|
3
|
-
include Glueby::Contract::TxBuilder
|
4
3
|
include Singleton
|
5
4
|
|
6
5
|
autoload :Tasks, 'glueby/utxo_provider/tasks'
|
@@ -77,26 +76,20 @@ module Glueby
|
|
77
76
|
# @return [Integer] current_amount The final amount of the tx inputs
|
78
77
|
# @return [Array<Hash>] provided_utxos The utxos that are added to the tx inputs
|
79
78
|
def fill_inputs(tx, target_amount: , current_amount: 0, fee_estimator: Contract::FeeEstimator::Fixed.new)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
utxos.each do |utxo|
|
90
|
-
tx.inputs << Tapyrus::TxIn.new(out_point: Tapyrus::OutPoint.from_txid(utxo[:txid], utxo[:vout]))
|
91
|
-
provided_utxos << utxo
|
92
|
-
end
|
93
|
-
current_amount += sum
|
94
|
-
|
95
|
-
new_fee = fee_estimator.fee(Contract::FeeEstimator.dummy_tx(tx, dummy_input_count: 0))
|
96
|
-
fee = new_fee
|
79
|
+
wallet.fill_uncolored_inputs(
|
80
|
+
tx,
|
81
|
+
target_amount: target_amount,
|
82
|
+
current_amount: current_amount,
|
83
|
+
fee_estimator: fee_estimator
|
84
|
+
) do |utxo|
|
85
|
+
# It must use only UTXOs that has defalut_value amount.
|
86
|
+
utxo[:amount] == default_value
|
97
87
|
end
|
88
|
+
end
|
89
|
+
alias fill_uncolored_inputs fill_inputs
|
98
90
|
|
99
|
-
|
91
|
+
def change_address
|
92
|
+
wallet.change_address
|
100
93
|
end
|
101
94
|
|
102
95
|
def default_value
|
@@ -153,22 +146,10 @@ module Glueby
|
|
153
146
|
# @return [Integer] sum The sum amount of the funds
|
154
147
|
# @return [Array<Hash>] outputs The UTXO set of the funds
|
155
148
|
def collect_uncolored_outputs(wallet, amount, excludes = [])
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
!excludes.find { |i| i[:txid] == o[:txid] && i[:vout] == o[:vout] }
|
160
|
-
end
|
161
|
-
utxos.shuffle!
|
162
|
-
|
163
|
-
utxos.inject([0, []]) do |(sum, outputs), output|
|
164
|
-
if wallet.lock_unspent(output)
|
165
|
-
sum += output[:amount]
|
166
|
-
outputs << output
|
167
|
-
return [sum, outputs] if sum >= amount
|
168
|
-
end
|
169
|
-
[sum, outputs]
|
149
|
+
wallet.collect_uncolored_outputs(amount, nil, true, true, true) do |utxo|
|
150
|
+
utxo[:amount] == default_value &&
|
151
|
+
!excludes.find { |i| i[:txid] == utxo[:txid] && i[:vout] == utxo[:vout] }
|
170
152
|
end
|
171
|
-
raise Glueby::Contract::Errors::InsufficientFunds
|
172
153
|
end
|
173
154
|
|
174
155
|
def validate_config!
|
data/lib/glueby/version.rb
CHANGED
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: 1.1
|
4
|
+
version: 1.2.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tapyrus
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 7.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 7.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 7.0.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 7.0.0
|
83
83
|
description: A Ruby library of smart contracts that can be used on Tapyrus.
|
84
84
|
email:
|
85
85
|
- azuchi@chaintope.com
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/glueby/generator.rb
|
143
143
|
- lib/glueby/generator/migrate_generator.rb
|
144
144
|
- lib/glueby/internal.rb
|
145
|
+
- lib/glueby/internal/contract_builder.rb
|
145
146
|
- lib/glueby/internal/rpc.rb
|
146
147
|
- lib/glueby/internal/wallet.rb
|
147
148
|
- lib/glueby/internal/wallet/abstract_wallet_adapter.rb
|
@@ -172,7 +173,7 @@ metadata:
|
|
172
173
|
homepage_uri: https://github.com/chaintope/glueby
|
173
174
|
source_code_uri: https://github.com/chaintope/glueby
|
174
175
|
changelog_uri: https://github.com/chaintope/glueby
|
175
|
-
post_install_message:
|
176
|
+
post_install_message:
|
176
177
|
rdoc_options: []
|
177
178
|
require_paths:
|
178
179
|
- lib
|
@@ -180,15 +181,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
181
|
requirements:
|
181
182
|
- - ">="
|
182
183
|
- !ruby/object:Gem::Version
|
183
|
-
version: 2.
|
184
|
+
version: 2.7.0
|
184
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
186
|
requirements:
|
186
|
-
- - "
|
187
|
+
- - ">"
|
187
188
|
- !ruby/object:Gem::Version
|
188
|
-
version:
|
189
|
+
version: 1.3.1
|
189
190
|
requirements: []
|
190
|
-
rubygems_version: 3.
|
191
|
-
signing_key:
|
191
|
+
rubygems_version: 3.4.10
|
192
|
+
signing_key:
|
192
193
|
specification_version: 4
|
193
194
|
summary: A Ruby library of smart contracts that can be used on Tapyrus.
|
194
195
|
test_files: []
|