glueby 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -1
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +3 -2
  5. data/README.md +27 -17
  6. data/glueby.gemspec +1 -1
  7. data/lib/generators/glueby/{initializer_generator.rb → contract/initializer_generator.rb} +0 -0
  8. data/lib/generators/glueby/contract/templates/initializer.rb.erb +3 -0
  9. data/lib/generators/glueby/contract/templates/key_table.rb.erb +15 -0
  10. data/lib/generators/glueby/{templates → contract/templates}/timestamp_table.rb.erb +2 -1
  11. data/lib/generators/glueby/contract/templates/utxo_table.rb.erb +15 -0
  12. data/lib/generators/glueby/contract/templates/wallet_table.rb.erb +10 -0
  13. data/lib/generators/glueby/contract/timestamp_generator.rb +26 -0
  14. data/lib/generators/glueby/contract/wallet_adapter_generator.rb +46 -0
  15. data/lib/glueby.rb +18 -1
  16. data/lib/glueby/contract.rb +3 -14
  17. data/lib/glueby/contract/active_record/timestamp.rb +8 -5
  18. data/lib/glueby/contract/errors.rb +6 -0
  19. data/lib/glueby/contract/payment.rb +54 -0
  20. data/lib/glueby/contract/timestamp.rb +39 -38
  21. data/lib/glueby/contract/token.rb +193 -0
  22. data/lib/glueby/contract/tx_builder.rb +197 -31
  23. data/lib/glueby/generator.rb +5 -0
  24. data/lib/glueby/generator/migrate_generator.rb +38 -0
  25. data/lib/glueby/internal.rb +6 -0
  26. data/lib/glueby/internal/rpc.rb +35 -0
  27. data/lib/glueby/internal/wallet.rb +122 -0
  28. data/lib/glueby/internal/wallet/abstract_wallet_adapter.rb +131 -0
  29. data/lib/glueby/internal/wallet/active_record.rb +15 -0
  30. data/lib/glueby/internal/wallet/active_record/key.rb +72 -0
  31. data/lib/glueby/internal/wallet/active_record/utxo.rb +50 -0
  32. data/lib/glueby/internal/wallet/active_record/wallet.rb +54 -0
  33. data/lib/glueby/internal/wallet/active_record_wallet_adapter.rb +133 -0
  34. data/lib/glueby/internal/wallet/errors.rb +11 -0
  35. data/lib/glueby/internal/wallet/tapyrus_core_wallet_adapter.rb +158 -0
  36. data/lib/glueby/version.rb +1 -1
  37. data/lib/glueby/wallet.rb +51 -0
  38. data/lib/tasks/glueby/contract/timestamp.rake +5 -5
  39. data/lib/tasks/glueby/contract/wallet_adapter.rake +42 -0
  40. metadata +30 -10
  41. data/lib/generators/glueby/templates/initializer.rb.erb +0 -4
  42. data/lib/generators/glueby/timestamp_generator.rb +0 -57
  43. data/lib/glueby/contract/rpc.rb +0 -15
@@ -1,4 +0,0 @@
1
- require 'tapyrus'
2
- # Edit configuration for connection to tapyrus core
3
- config = {schema: 'http', host: '127.0.0.1', port: 12381, user: 'user', password: 'pass'}
4
- Glueby::Contract::RPC.configure(config)
@@ -1,57 +0,0 @@
1
- module Glueby
2
- module Contract
3
- class TimestampGenerator < Rails::Generators::Base
4
- include ::Rails::Generators::Migration
5
-
6
- source_root File.expand_path('templates', __dir__)
7
-
8
- def self.next_migration_number(dirname)
9
- # ::ActiveRecord::Migration.next_migration_number(number)
10
- # ::ActiveRecord::Generators::Base.next_migration_number(dirname)
11
- next_migration_number = current_migration_number(dirname) + 1
12
- ::ActiveRecord::Migration.next_migration_number(next_migration_number)
13
- end
14
-
15
- def create_migration_file
16
- migration_dir = File.expand_path("db/migrate")
17
-
18
- if self.class.migration_exists?(migration_dir, "create_timestamp")
19
- ::Kernel.warn "Migration already exists: create_timestamp"
20
- else
21
- migration_template(
22
- "timestamp_table.rb.erb",
23
- "db/migrate/create_timestamp.rb",
24
- migration_version: migration_version,
25
- table_options: table_options,
26
- )
27
- end
28
- end
29
-
30
- MYSQL_ADAPTERS = [
31
- "ActiveRecord::ConnectionAdapters::MysqlAdapter",
32
- "ActiveRecord::ConnectionAdapters::Mysql2Adapter"
33
- ].freeze
34
-
35
- private
36
-
37
- def migration_version
38
- major = ::Rails::VERSION::MAJOR
39
- if major >= 5
40
- "[#{major}.#{::Rails::VERSION::MINOR}]"
41
- end
42
- end
43
-
44
- def mysql?
45
- MYSQL_ADAPTERS.include?(::ActiveRecord::Base.connection.class.name)
46
- end
47
-
48
- def table_options
49
- if mysql?
50
- ', { options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }'
51
- else
52
- ""
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,15 +0,0 @@
1
- module Glueby
2
- module Contract
3
- module RPC
4
- module_function
5
-
6
- def client
7
- @rpc
8
- end
9
-
10
- def configure(config)
11
- @rpc = Tapyrus::RPC::TapyrusCoreClient.new(config)
12
- end
13
- end
14
- end
15
- end