quorum_sdk 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,146 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Generated by the protocol buffer compiler. DO NOT EDIT!
4
- # source: lib/proto/activity_stream.proto
5
-
6
- require 'google/protobuf'
7
-
8
- require 'google/protobuf/timestamp_pb'
9
- require 'google/protobuf/any_pb'
10
-
11
- Google::Protobuf::DescriptorPool.generated_pool.build do
12
- add_file('lib/proto/activity_stream.proto', syntax: :proto3) do
13
- add_message 'quorum.pb.AnyObj' do
14
- optional :any, :message, 1, 'google.protobuf.Any'
15
- end
16
- add_message 'quorum.pb.Object' do
17
- optional :id, :string, 1
18
- optional :type, :string, 2
19
- repeated :attachments, :message, 3, 'quorum.pb.Object'
20
- repeated :attributedTo, :message, 4, 'quorum.pb.Object'
21
- optional :audience, :message, 5, 'quorum.pb.Object'
22
- optional :content, :string, 6
23
- optional :context, :message, 7, 'quorum.pb.Object'
24
- optional :name, :string, 8
25
- optional :endtime, :message, 9, 'google.protobuf.Timestamp'
26
- optional :generator, :message, 10, 'quorum.pb.Object'
27
- repeated :icon, :message, 11, 'quorum.pb.Object'
28
- repeated :image, :message, 12, 'quorum.pb.Image'
29
- optional :inreplyto, :message, 13, 'quorum.pb.Reply'
30
- optional :location, :message, 14, 'quorum.pb.Object'
31
- optional :preview, :message, 15, 'quorum.pb.Object'
32
- optional :published, :message, 16, 'google.protobuf.Timestamp'
33
- optional :replies, :message, 17, 'quorum.pb.Object'
34
- optional :startTime, :message, 18, 'google.protobuf.Timestamp'
35
- optional :summary, :string, 19
36
- repeated :tag, :message, 20, 'quorum.pb.Object'
37
- optional :updated, :message, 21, 'google.protobuf.Timestamp'
38
- repeated :url, :message, 22, 'quorum.pb.Link'
39
- repeated :to, :message, 23, 'quorum.pb.Object'
40
- repeated :bto, :message, 24, 'quorum.pb.Object'
41
- repeated :cc, :message, 25, 'quorum.pb.Object'
42
- repeated :bcc, :message, 26, 'quorum.pb.Object'
43
- optional :mediaType, :string, 27
44
- optional :duration, :string, 28
45
- optional :file, :message, 29, 'quorum.pb.File'
46
- end
47
- add_message 'quorum.pb.Link' do
48
- optional :href, :string, 1
49
- repeated :rel, :string, 2
50
- optional :mediaType, :string, 3
51
- optional :name, :string, 4
52
- optional :hreflang, :string, 5
53
- optional :height, :uint32, 6
54
- optional :width, :uint32, 7
55
- optional :preview, :message, 8, 'quorum.pb.Object'
56
- end
57
- add_message 'quorum.pb.Reply' do
58
- optional :trxid, :string, 1
59
- optional :groupid, :string, 2
60
- end
61
- add_message 'quorum.pb.Image' do
62
- optional :id, :string, 1
63
- optional :name, :string, 2
64
- optional :mediaType, :string, 3
65
- optional :content, :bytes, 4
66
- optional :url, :string, 5
67
- end
68
- add_message 'quorum.pb.File' do
69
- optional :id, :string, 1
70
- optional :name, :string, 2
71
- optional :mediaType, :string, 3
72
- optional :compression, :enum, 4, 'quorum.pb.File.Compression'
73
- optional :content, :bytes, 5
74
- optional :url, :string, 6
75
- end
76
- add_enum 'quorum.pb.File.Compression' do
77
- value :none, 0
78
- value :gz, 1
79
- value :zip, 2
80
- value :zstd, 3
81
- end
82
- add_message 'quorum.pb.Person' do
83
- optional :id, :string, 1
84
- optional :name, :string, 2
85
- optional :image, :message, 3, 'quorum.pb.Image'
86
- repeated :wallet, :message, 11, 'quorum.pb.Payment'
87
- end
88
- add_message 'quorum.pb.Payment' do
89
- optional :id, :string, 1
90
- optional :type, :string, 2
91
- optional :name, :string, 3
92
- end
93
- add_message 'quorum.pb.Activity' do
94
- optional :id, :string, 1
95
- optional :type, :string, 2
96
- repeated :attachments, :message, 3, 'quorum.pb.Object'
97
- repeated :attributedTo, :message, 4, 'quorum.pb.Object'
98
- optional :audience, :message, 5, 'quorum.pb.Object'
99
- optional :content, :string, 6
100
- optional :context, :message, 7, 'quorum.pb.Object'
101
- optional :name, :string, 8
102
- optional :endtime, :message, 9, 'google.protobuf.Timestamp'
103
- optional :generator, :message, 10, 'quorum.pb.Object'
104
- repeated :icon, :message, 11, 'quorum.pb.Object'
105
- repeated :image, :message, 12, 'quorum.pb.Object'
106
- optional :inReplyTo, :message, 13, 'quorum.pb.Object'
107
- optional :location, :message, 14, 'quorum.pb.Object'
108
- optional :preview, :message, 15, 'quorum.pb.Object'
109
- optional :published, :message, 16, 'google.protobuf.Timestamp'
110
- optional :replies, :message, 17, 'quorum.pb.Object'
111
- optional :startTime, :message, 18, 'google.protobuf.Timestamp'
112
- optional :summary, :string, 19
113
- repeated :tag, :message, 20, 'quorum.pb.Object'
114
- optional :updated, :message, 21, 'google.protobuf.Timestamp'
115
- repeated :url, :message, 22, 'quorum.pb.Link'
116
- repeated :to, :message, 23, 'quorum.pb.Object'
117
- repeated :bto, :message, 24, 'quorum.pb.Object'
118
- repeated :cc, :message, 25, 'quorum.pb.Object'
119
- repeated :bcc, :message, 26, 'quorum.pb.Object'
120
- optional :mediaType, :string, 27
121
- optional :duration, :string, 28
122
- optional :actor, :message, 29, 'quorum.pb.Object'
123
- optional :object, :message, 30, 'quorum.pb.Object'
124
- optional :target, :message, 31, 'quorum.pb.Object'
125
- optional :result, :message, 32, 'quorum.pb.Object'
126
- optional :origin, :message, 33, 'quorum.pb.Object'
127
- optional :instrument, :message, 34, 'quorum.pb.Object'
128
- optional :person, :message, 35, 'quorum.pb.Person'
129
- end
130
- end
131
- end
132
-
133
- module Quorum
134
- module Pb
135
- AnyObj = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.AnyObj').msgclass
136
- Object = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.Object').msgclass
137
- Link = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.Link').msgclass
138
- Reply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.Reply').msgclass
139
- Image = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.Image').msgclass
140
- File = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.File').msgclass
141
- File::Compression = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.File.Compression').enummodule
142
- Person = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.Person').msgclass
143
- Payment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.Payment').msgclass
144
- Activity = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('quorum.pb.Activity').msgclass
145
- end
146
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module QuorumSdk
4
- class API
5
- # Wrapper for HTTP APIs for chain
6
- module Chain
7
- def trx(trx_id)
8
- path = "api/v1/trx/#{group_id}/#{trx_id}"
9
- r = client.get(path).body
10
- r =
11
- begin
12
- JSON.parse r
13
- rescue JSON::ParserError
14
- r
15
- end
16
-
17
- if r['Data'].present?
18
- data = Base64.strict_decode64 r['Data']
19
- r['Data'] = QuorumSdk::Utils.decrypt_trx_data data, key: cipher_key
20
- end
21
-
22
- r
23
- end
24
- end
25
- end
26
- end
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module QuorumSdk
4
- class API
5
- # Wrapper for HTTP APIs for light node
6
- module LightNode
7
- ARGUMENTS_FOR_BUILD_TRX = %i[private_key data].freeze
8
- def build_trx(**kwargs)
9
- raise ArgumentError, "Keyword arguments #{ARGUMENTS_FOR_BUILD_TRX} must be provided" unless ARGUMENTS_FOR_BUILD_TRX.all?(&->(arg) { arg.in? kwargs.keys })
10
-
11
- kwargs = kwargs.merge(
12
- group_id:,
13
- cipher_key:
14
- )
15
- QuorumSdk::Utils.encrypt_trx(**kwargs)
16
- end
17
-
18
- def send_trx(trx_item)
19
- path = "api/v1/node/trx/#{group_id}"
20
- client.post(path, TrxItem: trx_item).body
21
- end
22
-
23
- def list_trx(**kwargs)
24
- params = {
25
- group_id:,
26
- start_trx: kwargs[:start_trx],
27
- num: kwargs[:num] || 100,
28
- senders: kwargs[:senders].presence || []
29
- }.compact
30
- params[:reverse] =
31
- if kwargs[:reverse]
32
- 'true'
33
- else
34
- 'false'
35
- end
36
- params[:include_start_trx] =
37
- if kwargs[:include_start_trx]
38
- 'true'
39
- else
40
- 'false'
41
- end
42
-
43
- encrypted_params = QuorumSdk::Utils.aes_encrypt({
44
- Req: params
45
- }.to_json, key: cipher_key)
46
-
47
- payload = {
48
- Req: Base64.strict_encode64(encrypted_params)
49
- }
50
-
51
- path = "api/v1/node/groupctn/#{group_id}"
52
- list = client.post(path, **payload).body
53
-
54
- return list unless list.is_a?(Array)
55
-
56
- list.each do |trx|
57
- next if trx['Data'].blank?
58
-
59
- data = Base64.strict_decode64 trx['Data']
60
- trx['Data'] = QuorumSdk::Utils.decrypt_trx_data data, key: cipher_key
61
- end
62
-
63
- list
64
- end
65
-
66
- def chain_data(params, type)
67
- path = "api/v1/node/getchaindata/#{group_id}"
68
- encrypted_params = QuorumSdk::Utils.aes_encrypt params.to_json, key: cipher_key
69
- encoded_params = Base64.strict_encode64 encrypted_params
70
-
71
- payload = {
72
- Req: encoded_params,
73
- ReqType: type
74
- }
75
-
76
- client.post(path, **payload).body
77
- end
78
-
79
- def group_info
80
- chain_data({ GroupId: group_id }, 'group_info')
81
- end
82
- end
83
- end
84
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'api/chain'
4
- require_relative 'api/group'
5
- require_relative 'api/light_node'
6
- require_relative 'api/management'
7
- require_relative 'client'
8
-
9
- module QuorumSdk
10
- # Wrapper for HTTP APIs
11
- class API
12
- attr_reader :group_id, :group_name, :consensus_type, :encryption_type, :app_key, :owner_pubkey, :signature,
13
- :cipher_key, :chain_urls, :client
14
-
15
- def initialize(**kwargs)
16
- config =
17
- if kwargs[:seed_url].present?
18
- QuorumSdk::Utils.parse_seed_url kwargs[:seed_url]
19
- else
20
- kwargs
21
- end
22
-
23
- @group_id = config[:group_id]
24
- @group_name = config[:group_name]
25
- @consensus_type = config[:consensus_type]
26
- @encryption_type = config[:encryption_type]
27
- @app_key = config[:app_key]
28
- @owner_pubkey = config[:owner_pubkey]
29
- @signature = config[:signature]
30
- @cipher_key = config[:cipher_key]
31
- @chain_urls = config[:chain_urls]
32
-
33
- @client = QuorumSdk::Client.new(@chain_urls)
34
- end
35
-
36
- include QuorumSdk::API::Chain
37
- include QuorumSdk::API::Group
38
- include QuorumSdk::API::LightNode
39
- include QuorumSdk::API::Management
40
- end
41
- end