glueby 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +35 -0
  3. data/Gemfile +1 -0
  4. data/README.md +111 -6
  5. data/glueby.gemspec +1 -1
  6. data/lib/generators/glueby/contract/reissuable_token_generator.rb +26 -0
  7. data/lib/generators/glueby/contract/templates/key_table.rb.erb +3 -3
  8. data/lib/generators/glueby/contract/templates/reissuable_token_table.rb.erb +10 -0
  9. data/lib/generators/glueby/contract/templates/system_information_table.rb.erb +2 -2
  10. data/lib/generators/glueby/contract/templates/timestamp_table.rb.erb +1 -1
  11. data/lib/generators/glueby/contract/templates/utxo_table.rb.erb +2 -2
  12. data/lib/generators/glueby/contract/templates/wallet_table.rb.erb +2 -2
  13. data/lib/glueby.rb +25 -0
  14. data/lib/glueby/configuration.rb +62 -0
  15. data/lib/glueby/contract.rb +2 -2
  16. data/lib/glueby/contract/active_record.rb +1 -0
  17. data/lib/glueby/contract/active_record/reissuable_token.rb +26 -0
  18. data/lib/glueby/contract/fee_estimator.rb +38 -0
  19. data/lib/glueby/contract/payment.rb +4 -4
  20. data/lib/glueby/contract/timestamp.rb +6 -6
  21. data/lib/glueby/contract/token.rb +69 -22
  22. data/lib/glueby/contract/tx_builder.rb +22 -19
  23. data/lib/glueby/fee_provider.rb +73 -0
  24. data/lib/glueby/fee_provider/tasks.rb +136 -0
  25. data/lib/glueby/generator/migrate_generator.rb +1 -1
  26. data/lib/glueby/internal/wallet.rb +28 -4
  27. data/lib/glueby/internal/wallet/abstract_wallet_adapter.rb +18 -3
  28. data/lib/glueby/internal/wallet/active_record/wallet.rb +15 -5
  29. data/lib/glueby/internal/wallet/active_record_wallet_adapter.rb +15 -5
  30. data/lib/glueby/internal/wallet/errors.rb +3 -0
  31. data/lib/glueby/internal/wallet/tapyrus_core_wallet_adapter.rb +36 -11
  32. data/lib/glueby/version.rb +1 -1
  33. data/lib/glueby/wallet.rb +3 -2
  34. data/lib/tasks/glueby/contract/timestamp.rake +1 -1
  35. data/lib/tasks/glueby/fee_provider.rake +13 -0
  36. metadata +16 -9
  37. data/.travis.yml +0 -7
  38. data/lib/glueby/contract/fee_provider.rb +0 -21
data/lib/glueby/wallet.rb CHANGED
@@ -13,6 +13,7 @@ module Glueby
13
13
  new(Glueby::Internal::Wallet.load(wallet_id))
14
14
  end
15
15
 
16
+ # @deprecated - Use Glueby.configure instead
16
17
  def configure(config)
17
18
  case config[:adapter]
18
19
  when 'core'
@@ -32,8 +33,8 @@ module Glueby
32
33
  end
33
34
 
34
35
  # @return [HashMap] hash of balances which key is color_id or empty string, and value is amount
35
- def balances
36
- utxos = @internal_wallet.list_unspent
36
+ def balances(only_finalized = true)
37
+ utxos = @internal_wallet.list_unspent(only_finalized)
37
38
  utxos.inject({}) do |balances, output|
38
39
  key = output[:color_id] || ''
39
40
  balances[key] ||= 0
@@ -12,7 +12,7 @@ module Glueby
12
12
  begin
13
13
  ::ActiveRecord::Base.transaction do
14
14
  wallet = Glueby::Wallet.load(t.wallet_id)
15
- tx = create_tx(wallet, t.prefix, t.content_hash, Glueby::Contract::FixedFeeProvider.new)
15
+ tx = create_tx(wallet, t.prefix, t.content_hash, Glueby::Contract::FixedFeeEstimator.new)
16
16
  t.update(txid: tx.txid, status: :unconfirmed)
17
17
 
18
18
  wallet.internal_wallet.broadcast(tx)
@@ -0,0 +1,13 @@
1
+ namespace :glueby do
2
+ namespace :fee_provider do
3
+ desc 'Manage the UTXO pool in Glueby::FeeProvider. Creates outputs for paying fee if the outputs is less than configured pool size by :utxo_pool_size'
4
+ task :manage_utxo_pool, [] => [:environment] do |_, _|
5
+ Glueby::FeeProvider::Tasks.new.manage_utxo_pool
6
+ end
7
+
8
+ desc 'Show the status of the UTXO pool in Glueby::FeeProvider'
9
+ task :status, [] => [:environment] do |_, _|
10
+ Glueby::FeeProvider::Tasks.new.status
11
+ end
12
+ end
13
+ 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.3.0
4
+ version: 0.4.0
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-03-23 00:00:00.000000000 Z
11
+ date: 2021-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tapyrus
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.6
19
+ version: 0.2.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.6
26
+ version: 0.2.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,11 +59,11 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/ruby.yml"
62
63
  - ".gitignore"
63
64
  - ".rspec"
64
65
  - ".ruby-gemset"
65
66
  - ".ruby-version"
66
- - ".travis.yml"
67
67
  - CODE_OF_CONDUCT.md
68
68
  - Gemfile
69
69
  - LICENSE.txt
@@ -74,8 +74,10 @@ files:
74
74
  - glueby.gemspec
75
75
  - lib/generators/glueby/contract/block_syncer_generator.rb
76
76
  - lib/generators/glueby/contract/initializer_generator.rb
77
+ - lib/generators/glueby/contract/reissuable_token_generator.rb
77
78
  - lib/generators/glueby/contract/templates/initializer.rb.erb
78
79
  - lib/generators/glueby/contract/templates/key_table.rb.erb
80
+ - lib/generators/glueby/contract/templates/reissuable_token_table.rb.erb
79
81
  - lib/generators/glueby/contract/templates/system_information_table.rb.erb
80
82
  - lib/generators/glueby/contract/templates/timestamp_table.rb.erb
81
83
  - lib/generators/glueby/contract/templates/utxo_table.rb.erb
@@ -85,15 +87,19 @@ files:
85
87
  - lib/glueby.rb
86
88
  - lib/glueby/active_record.rb
87
89
  - lib/glueby/active_record/system_information.rb
90
+ - lib/glueby/configuration.rb
88
91
  - lib/glueby/contract.rb
89
92
  - lib/glueby/contract/active_record.rb
93
+ - lib/glueby/contract/active_record/reissuable_token.rb
90
94
  - lib/glueby/contract/active_record/timestamp.rb
91
95
  - lib/glueby/contract/errors.rb
92
- - lib/glueby/contract/fee_provider.rb
96
+ - lib/glueby/contract/fee_estimator.rb
93
97
  - lib/glueby/contract/payment.rb
94
98
  - lib/glueby/contract/timestamp.rb
95
99
  - lib/glueby/contract/token.rb
96
100
  - lib/glueby/contract/tx_builder.rb
101
+ - lib/glueby/fee_provider.rb
102
+ - lib/glueby/fee_provider/tasks.rb
97
103
  - lib/glueby/generator.rb
98
104
  - lib/glueby/generator/migrate_generator.rb
99
105
  - lib/glueby/internal.rb
@@ -113,6 +119,7 @@ files:
113
119
  - lib/tasks/glueby/contract/block_syncer.rake
114
120
  - lib/tasks/glueby/contract/timestamp.rake
115
121
  - lib/tasks/glueby/contract/wallet_adapter.rake
122
+ - lib/tasks/glueby/fee_provider.rake
116
123
  homepage: https://github.com/chaintope/glueby
117
124
  licenses:
118
125
  - MIT
@@ -120,7 +127,7 @@ metadata:
120
127
  homepage_uri: https://github.com/chaintope/glueby
121
128
  source_code_uri: https://github.com/chaintope/glueby
122
129
  changelog_uri: https://github.com/chaintope/glueby
123
- post_install_message:
130
+ post_install_message:
124
131
  rdoc_options: []
125
132
  require_paths:
126
133
  - lib
@@ -136,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
143
  version: '0'
137
144
  requirements: []
138
145
  rubygems_version: 3.2.3
139
- signing_key:
146
+ signing_key:
140
147
  specification_version: 4
141
148
  summary: A Ruby library of smart contracts that can be used on Tapyrus.
142
149
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.6
6
- - 2.7.2
7
- - 3.0.0
@@ -1,21 +0,0 @@
1
- module Glueby
2
- module Contract
3
- module FeeProvider
4
- # @return fee by tapyrus(not TPC).
5
- def fee(_tx); end
6
- end
7
-
8
- class FixedFeeProvider
9
- include FeeProvider
10
-
11
- def initialize(fixed_fee: 10_000)
12
- @fixed_fee = fixed_fee
13
- end
14
-
15
- # @return fee by tapyrus(not TPC).
16
- def fee(_tx)
17
- @fixed_fee
18
- end
19
- end
20
- end
21
- end