istox 0.2.6.pre.2 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +33 -15
- data/lib/istox/helpers/messaging.rb +22 -2
- data/lib/istox/helpers/order_book_prorate.rb +17 -3
- data/lib/istox/helpers/redis_manager.rb +3 -3
- data/lib/istox/helpers/sns_publisher.rb +7 -3
- data/lib/istox/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 994fc5810c55f2637b138a872add0d6cc3eb3b3b0f4720d3121ada69bffcd037
|
4
|
+
data.tar.gz: f90911bd0bb0673a231e76fa4f26820b0ba96039d745aa2f23d0dd09be3e9e3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8973bb6040837fd3937f0e85576c8e312a1485dbed490e1d9981a5e7fee3762707443f64194df33f69940072c59a627ea9442495959bbae59b80694de929971
|
7
|
+
data.tar.gz: bc817295ac6e4b1d82ec546f7c0537d23d2e2dc980b02c735aa05e5c97d1fd959bc9f8d1189cf03afe6509be87b0bc078b8865a8b0c9fc2bdc214203ec7f2556
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
istox (0.2.
|
4
|
+
istox (0.2.5.3)
|
5
5
|
amazing_print
|
6
6
|
awesome_print
|
7
7
|
aws-sdk-sns (~> 1)
|
@@ -9,6 +9,7 @@ PATH
|
|
9
9
|
bunny (>= 2.12.0)
|
10
10
|
exponential-backoff (= 0.0.4)
|
11
11
|
graphlient
|
12
|
+
gruf
|
12
13
|
hashie (~> 3.5.7)
|
13
14
|
istox_gruf (~> 2.7.3)
|
14
15
|
listen (~> 3.0.5)
|
@@ -66,7 +67,7 @@ GEM
|
|
66
67
|
amazing_print (1.3.0)
|
67
68
|
amq-protocol (2.3.2)
|
68
69
|
arel (9.0.0)
|
69
|
-
awesome_print (1.
|
70
|
+
awesome_print (1.9.2)
|
70
71
|
aws-eventstream (1.1.0)
|
71
72
|
aws-partitions (1.318.0)
|
72
73
|
aws-sdk-core (3.96.1)
|
@@ -100,6 +101,7 @@ GEM
|
|
100
101
|
database_cleaner (1.6.2)
|
101
102
|
debug_inspector (1.1.0)
|
102
103
|
diff-lcs (1.3)
|
104
|
+
e2mmap (0.1.0)
|
103
105
|
erubi (1.9.0)
|
104
106
|
exponential-backoff (0.0.4)
|
105
107
|
factory_bot (4.8.2)
|
@@ -111,31 +113,44 @@ GEM
|
|
111
113
|
i18n (~> 0.5)
|
112
114
|
fakeredis (0.7.0)
|
113
115
|
redis (>= 3.2, < 5.0)
|
114
|
-
faraday (1.
|
116
|
+
faraday (1.4.1)
|
117
|
+
faraday-excon (~> 1.1)
|
115
118
|
faraday-net_http (~> 1.0)
|
119
|
+
faraday-net_http_persistent (~> 1.1)
|
116
120
|
multipart-post (>= 1.2, < 3)
|
117
|
-
ruby2_keywords
|
121
|
+
ruby2_keywords (>= 0.0.4)
|
122
|
+
faraday-excon (1.1.0)
|
118
123
|
faraday-net_http (1.0.1)
|
124
|
+
faraday-net_http_persistent (1.1.0)
|
119
125
|
faraday_middleware (1.0.0)
|
120
126
|
faraday (~> 1.0)
|
121
127
|
ffi (1.15.0)
|
122
128
|
globalid (0.4.2)
|
123
129
|
activesupport (>= 4.2.0)
|
124
|
-
google-protobuf (3.
|
125
|
-
googleapis-common-protos-types (1.0.
|
126
|
-
google-protobuf (~> 3.
|
130
|
+
google-protobuf (3.15.8-universal-darwin)
|
131
|
+
googleapis-common-protos-types (1.0.6)
|
132
|
+
google-protobuf (~> 3.14)
|
127
133
|
graphlient (0.5.0)
|
128
134
|
faraday (>= 1.0)
|
129
135
|
faraday_middleware
|
130
136
|
graphql-client
|
131
|
-
graphql (1.
|
137
|
+
graphql (1.12.8)
|
132
138
|
graphql-client (0.16.0)
|
133
139
|
activesupport (>= 3.0)
|
134
140
|
graphql (~> 1.8)
|
135
|
-
grpc (1.
|
136
|
-
google-protobuf (~> 3.
|
141
|
+
grpc (1.37.0-universal-darwin)
|
142
|
+
google-protobuf (~> 3.15)
|
137
143
|
googleapis-common-protos-types (~> 1.0)
|
138
|
-
grpc-tools (1.
|
144
|
+
grpc-tools (1.37.0)
|
145
|
+
gruf (2.9.1)
|
146
|
+
activesupport (> 4)
|
147
|
+
concurrent-ruby (> 1)
|
148
|
+
e2mmap (~> 0.1)
|
149
|
+
grpc (~> 1.10)
|
150
|
+
grpc-tools (~> 1.10)
|
151
|
+
json (>= 2.3)
|
152
|
+
slop (~> 4.6)
|
153
|
+
thwait (~> 0.1)
|
139
154
|
hashie (3.5.7)
|
140
155
|
i18n (0.9.5)
|
141
156
|
concurrent-ruby (~> 1.0)
|
@@ -146,6 +161,7 @@ GEM
|
|
146
161
|
grpc-tools (~> 1.10)
|
147
162
|
slop (~> 4.6)
|
148
163
|
jmespath (1.4.0)
|
164
|
+
json (2.5.1)
|
149
165
|
listen (3.0.8)
|
150
166
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
151
167
|
rb-inotify (~> 0.9, >= 0.9.7)
|
@@ -166,8 +182,8 @@ GEM
|
|
166
182
|
nio4r (2.3.1)
|
167
183
|
nokogiri (1.10.9)
|
168
184
|
mini_portile2 (~> 2.4.0)
|
169
|
-
oj (3.
|
170
|
-
ougai (
|
185
|
+
oj (3.11.5)
|
186
|
+
ougai (2.0.0)
|
171
187
|
oj (~> 3.10)
|
172
188
|
paranoia (2.4.3)
|
173
189
|
activerecord (>= 4.0, < 6.2)
|
@@ -218,7 +234,7 @@ GEM
|
|
218
234
|
redis-activesupport (5.2.0)
|
219
235
|
activesupport (>= 3, < 7)
|
220
236
|
redis-store (>= 1.3, < 2)
|
221
|
-
redis-namespace (1.8.
|
237
|
+
redis-namespace (1.8.1)
|
222
238
|
redis (>= 3.0.4)
|
223
239
|
redis-rack (2.1.3)
|
224
240
|
rack (>= 2.0.8, < 3)
|
@@ -250,7 +266,7 @@ GEM
|
|
250
266
|
rspec-mocks (~> 3.8.0)
|
251
267
|
rspec-support (~> 3.8.0)
|
252
268
|
rspec-support (3.8.0)
|
253
|
-
ruby2_keywords (0.0.
|
269
|
+
ruby2_keywords (0.0.4)
|
254
270
|
slop (4.8.2)
|
255
271
|
sprockets (3.7.2)
|
256
272
|
concurrent-ruby (~> 1.0)
|
@@ -262,6 +278,8 @@ GEM
|
|
262
278
|
sqlite3 (1.3.13)
|
263
279
|
thor (0.20.3)
|
264
280
|
thread_safe (0.3.6)
|
281
|
+
thwait (0.2.0)
|
282
|
+
e2mmap
|
265
283
|
timecop (0.9.1)
|
266
284
|
tzinfo (1.2.6)
|
267
285
|
thread_safe (~> 0.1)
|
@@ -23,7 +23,7 @@ module Istox
|
|
23
23
|
type: 'SEND_SMS',
|
24
24
|
data: {
|
25
25
|
to: targets,
|
26
|
-
subject: subject || 'Message from
|
26
|
+
subject: subject || 'Message from ADDX',
|
27
27
|
body: content
|
28
28
|
}
|
29
29
|
}
|
@@ -130,7 +130,8 @@ module Istox
|
|
130
130
|
email_data[:copy_emails].each do |ce|
|
131
131
|
next unless ce.present?
|
132
132
|
|
133
|
-
|
133
|
+
# uid and sid are reserved fields that should be not cloned
|
134
|
+
copy_email_data = email_data.clone.except(:sid).except(:uid)
|
134
135
|
|
135
136
|
# if it is just email to cc
|
136
137
|
if ce.is_a? String
|
@@ -160,6 +161,25 @@ module Istox
|
|
160
161
|
end
|
161
162
|
template_data_arr.concat(copy_email_data_arr)
|
162
163
|
end
|
164
|
+
|
165
|
+
def push_notification(template_name, template_data_arr)
|
166
|
+
raise ArgumentError, 'Template name and template data arr cannot be empty' if template_name.blank? || template_data_arr.nil?
|
167
|
+
|
168
|
+
return log.info 'Template data is empty, skipping this request' if template_data_arr.empty?
|
169
|
+
|
170
|
+
::Istox::Publisher.manual_publish(
|
171
|
+
exchange: 'message',
|
172
|
+
exchange_type: 'direct',
|
173
|
+
routing_key: 'push_notification.message',
|
174
|
+
message: {
|
175
|
+
type: 'SEND_PUSH_NOTIFICATION',
|
176
|
+
data: {
|
177
|
+
template_name: template_name,
|
178
|
+
template_data_arr_json: template_data_arr.to_json
|
179
|
+
}
|
180
|
+
}
|
181
|
+
)
|
182
|
+
end
|
163
183
|
end
|
164
184
|
end
|
165
185
|
end
|
@@ -2,12 +2,19 @@ module Istox
|
|
2
2
|
class OrderBookProrate
|
3
3
|
class << self
|
4
4
|
def allocation(token_price:, min_investment:, bid_block:, # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
|
5
|
-
invest_step:, hard_cap:, investments:, whitelists: [], include_refund_amount: false
|
5
|
+
invest_step:, hard_cap:, investments:, whitelists: [], include_refund_amount: false,
|
6
|
+
rollover_investments: [])
|
6
7
|
|
7
8
|
# make sure is hashes
|
8
9
|
original_investments = investments.as_json.map(&:symbolize_keys)
|
9
10
|
whitelists = whitelists.as_json.map(&:symbolize_keys)
|
10
11
|
investments = investments.as_json.map(&:symbolize_keys)
|
12
|
+
rollover_investments = rollover_investments.as_json.map(&:symbolize_keys)
|
13
|
+
|
14
|
+
## rollover investment is guaranteed, so it should decrease the hard cap
|
15
|
+
rollover_investments.map do |rollover_investment|
|
16
|
+
hard_cap = ::Istox::FMath.sub(hard_cap, rollover_investment[:fiat_amount])
|
17
|
+
end
|
11
18
|
|
12
19
|
# process whitelist
|
13
20
|
whitelists.each do |whitelist|
|
@@ -106,7 +113,7 @@ module Istox
|
|
106
113
|
|
107
114
|
if include_refund_amount
|
108
115
|
original_investment = original_investments.find { |original_investment1| original_investment1[:id] == interest[:id] }
|
109
|
-
interest[:refund_amount] = ::Istox::FMath.sub(original_investment[:fiat_amount], interest[:investment])
|
116
|
+
interest[:refund_amount] = original_investment.present? ? ::Istox::FMath.sub(original_investment[:fiat_amount], interest[:investment]) : '0'
|
110
117
|
end
|
111
118
|
interest
|
112
119
|
end
|
@@ -139,9 +146,16 @@ module Istox
|
|
139
146
|
end
|
140
147
|
end
|
141
148
|
|
149
|
+
transform_rollover_investments = rollover_investments.map do |rollover_investment|
|
150
|
+
rollover_investment[:investment] = ::BigDecimal.new(rollover_investment[:fiat_amount].to_s).to_s
|
151
|
+
rollover_investment[:refund_amount] = ::BigDecimal.new(0).to_s if include_refund_amount
|
152
|
+
|
153
|
+
rollover_investment.select { |k, _v| %i[id investment refund_amount].include?(k) }
|
154
|
+
end
|
155
|
+
|
142
156
|
{
|
143
157
|
cutoff_price: token_price.to_s,
|
144
|
-
interests: final_interests
|
158
|
+
interests: final_interests.concat(transform_rollover_investments)
|
145
159
|
}
|
146
160
|
end
|
147
161
|
end
|
@@ -17,9 +17,9 @@ module Istox
|
|
17
17
|
))
|
18
18
|
end
|
19
19
|
|
20
|
-
# for
|
21
|
-
def
|
22
|
-
@
|
20
|
+
# for rate limit redis cache
|
21
|
+
def rate_limit_redis
|
22
|
+
@rate_limit_redis ||= Redis::Namespace.new(:rate_limit_cache, redis: Redis.new(
|
23
23
|
url: ENV['REDIS_URL'] || 'redis://127.0.0.1:16379',
|
24
24
|
db: 6
|
25
25
|
))
|
@@ -14,12 +14,16 @@ module Istox
|
|
14
14
|
|
15
15
|
message = JSON.generate(message) unless message.is_a? String
|
16
16
|
|
17
|
-
|
17
|
+
topic = topic_arn || ENV.fetch('SNS_CLIENT_TOPIC', '')
|
18
|
+
|
19
|
+
log.info("Publishing SNS to topic: #{topic} with message: #{message}")
|
20
|
+
|
21
|
+
sns_client.publish(topic_arn: topic, message: message)
|
18
22
|
|
19
23
|
log.info('Publish to SNS successfully.')
|
20
24
|
rescue StandardError => e
|
21
|
-
log.
|
22
|
-
log.
|
25
|
+
log.info 'Unable to publish SNS message.'
|
26
|
+
log.info(e)
|
23
27
|
log.info('Failed to publish SNS, ignoring...') unless throw_exception
|
24
28
|
|
25
29
|
raise e if throw_exception
|
data/lib/istox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: istox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -517,7 +517,7 @@ files:
|
|
517
517
|
homepage: http://www.abc.com
|
518
518
|
licenses: []
|
519
519
|
metadata: {}
|
520
|
-
post_install_message:
|
520
|
+
post_install_message:
|
521
521
|
rdoc_options: []
|
522
522
|
require_paths:
|
523
523
|
- lib
|
@@ -528,12 +528,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
528
528
|
version: '0'
|
529
529
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
530
530
|
requirements:
|
531
|
-
- - "
|
531
|
+
- - ">="
|
532
532
|
- !ruby/object:Gem::Version
|
533
|
-
version:
|
533
|
+
version: '0'
|
534
534
|
requirements: []
|
535
|
-
rubygems_version: 3.0.
|
536
|
-
signing_key:
|
535
|
+
rubygems_version: 3.0.6
|
536
|
+
signing_key:
|
537
537
|
specification_version: 4
|
538
538
|
summary: istox backend shared gem
|
539
539
|
test_files: []
|