glueby 0.6.1 → 0.6.2

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: 2b053cde5755947020d018939a4efa0a042e830232aff3e4d2a4a4a9b53caa54
4
- data.tar.gz: 5fcfb3f983b687f6942901d7f56c9f70a5123b97e0f5eb313d3a011632824f76
3
+ metadata.gz: bd80045038551e7ffc41a613fb67401f3675c79098222e335359209070ff280a
4
+ data.tar.gz: f966a44bb7de60429e91d39681f63c6b827dbcb8806700cbfe6b5e961f013b2d
5
5
  SHA512:
6
- metadata.gz: 440cd7203e5d411dc0aca3571e2eaa14b2c2ef85ca97d9ed60c7b9099d206dc9d4fbaa4dfb65190ddcc9fc71bbb57555abc42cde5cf2d3319fa4c8c18f3b70cf
7
- data.tar.gz: 4dac9b8cb1a8a6670e8ee0458f467c66c91994b103e8d9513bbbfb926c27f9b0541de4bdfe12085edb58b1ac9f761775abf88f3dcb93ab43f9ba17ad0c96f840
6
+ metadata.gz: 4e443a845c4d65eeba06c83d40617497b984f8a0c158e54debb1ac82d762af53ebba8073e8fc18855f93816370dc8969657bec8d8e95d5990df3fe50c9c7471a
7
+ data.tar.gz: 2c5f2670b48f6a1149052b239d89c626c323e21f222bd2deb201074b96d54ac935080624cb92a2399414aed03de44258a41da5b0fc4ecc5221d854ef201c06de
@@ -19,9 +19,8 @@ module Glueby
19
19
  module_function
20
20
 
21
21
  # @param [Glueby::Wallet] wallet
22
- # @param [Array] data The data to be used for generating pay-to-contract address
23
- # @return [Array(String, String)]
24
- # Return (pay-to-contract address, public key used for generating address)
22
+ # @param [Array] contents The data to be used for generating pay-to-contract address
23
+ # @return [pay-to-contract address, public key used for generating address]
25
24
  def create_pay_to_contract_address(wallet, contents: nil)
26
25
  pubkey = wallet.internal_wallet.create_pubkey.pubkey
27
26
  # Calculate P + H(P || contents)G
@@ -44,7 +44,7 @@ module Glueby
44
44
 
45
45
  fee = fee_estimator.fee(dummy_tx(txb.build))
46
46
  # The outputs need to be shuffled so that no utxos are spent twice as possible.
47
- sum, outputs = wallet.collect_uncolored_outputs(fee + value, nil, true, true)
47
+ sum, outputs = collect_uncolored_outputs(wallet, fee + value)
48
48
 
49
49
  outputs.each do |utxo|
50
50
  txb.add_utxo({
@@ -73,6 +73,20 @@ module Glueby
73
73
  end
74
74
  end
75
75
 
76
+ def collect_uncolored_outputs(wallet, amount)
77
+ utxos = wallet.list_unspent.select { |o| !o[:color_id] && o[:amount] == @default_value }
78
+ utxos.shuffle!
79
+
80
+ utxos.inject([0, []]) do |sum, output|
81
+ new_sum = sum[0] + output[:amount]
82
+ new_outputs = sum[1] << output
83
+ return [new_sum, new_outputs] if new_sum >= amount
84
+
85
+ [new_sum, new_outputs]
86
+ end
87
+ raise Glueby::Contract::Errors::InsufficientFunds
88
+ end
89
+
76
90
  def validate_config!
77
91
  if UtxoProvider.config
78
92
  utxo_pool_size = UtxoProvider.config[:utxo_pool_size]
@@ -1,3 +1,3 @@
1
1
  module Glueby
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tapyrus
@@ -147,7 +147,7 @@ metadata:
147
147
  homepage_uri: https://github.com/chaintope/glueby
148
148
  source_code_uri: https://github.com/chaintope/glueby
149
149
  changelog_uri: https://github.com/chaintope/glueby
150
- post_install_message:
150
+ post_install_message:
151
151
  rdoc_options: []
152
152
  require_paths:
153
153
  - lib
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubygems_version: 3.2.3
166
- signing_key:
166
+ signing_key:
167
167
  specification_version: 4
168
168
  summary: A Ruby library of smart contracts that can be used on Tapyrus.
169
169
  test_files: []