cns 0.1.1 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.reek.yml +64 -0
- data/.rubocop.yml +4 -3
- data/Gemfile.lock +71 -9
- data/cns.gemspec +9 -6
- data/lib/cns.rb +4 -15
- data/lib/cns/apibc.rb +266 -0
- data/lib/cns/apice1.rb +177 -0
- data/lib/cns/apice2.rb +323 -0
- data/lib/cns/bigquery1.rb +22 -19
- data/lib/cns/bigquery2.rb +8 -6
- data/lib/cns/bigquery3.rb +85 -58
- data/lib/cns/bigquery4.rb +81 -82
- data/lib/cns/bitcoinde.rb +65 -53
- data/lib/cns/etherscan1.rb +48 -45
- data/lib/cns/etherscan2.rb +30 -28
- data/lib/cns/greymass1.rb +44 -38
- data/lib/cns/greymass2.rb +28 -45
- data/lib/cns/kraken.rb +57 -45
- data/lib/cns/paymium.rb +47 -40
- data/lib/cns/therock.rb +43 -34
- data/lib/cns/version.rb +1 -1
- metadata +70 -16
- data/lib/cns/apide.rb +0 -240
- data/lib/cns/apies.rb +0 -161
- data/lib/cns/apifr.rb +0 -139
- data/lib/cns/apigm.rb +0 -181
- data/lib/cns/apimt.rb +0 -138
- data/lib/cns/apius.rb +0 -167
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ef054c95506b8f32415f3c3f47b2272886ac824f10666c91a4bd0f3b118b3ffb
|
|
4
|
+
data.tar.gz: c18711c2d3ffcdf131218d3509f954f163046fa5b498e39b47e15332b3fb53a1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef30f7f2617710c765d6dd8d4a21e673a55da5aa59ee4bb1ac15343c70a9ee5cfa7b9e26ccc01019c53cbd69d571fd07981e3bba35fbc53a04d308ccd61d118c
|
|
7
|
+
data.tar.gz: df9e5fbe45744df8bb75dc5b8145fe8f875a6085877d8709e9cc7d2cf5a907ec797a9cad8f3c557b7599bfc079873822e7c4aa390334e8696dd3b21aa57c0db5
|
data/.reek.yml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
detectors:
|
|
3
|
+
TooManyStatements:
|
|
4
|
+
exclude:
|
|
5
|
+
- initialize
|
|
6
|
+
max_statements: 10
|
|
7
|
+
RepeatedConditional:
|
|
8
|
+
exclude:
|
|
9
|
+
- "Cns::Apice"
|
|
10
|
+
FeatureEnvy:
|
|
11
|
+
exclude:
|
|
12
|
+
- "Cns::Apice#deposit_unif"
|
|
13
|
+
- "Cns::Apice#withdrawal_unif"
|
|
14
|
+
- "Cns::Bigquery#etht_1val"
|
|
15
|
+
- "Cns::Bigquery#etht_2val"
|
|
16
|
+
- "Cns::Bigquery#etht_3val"
|
|
17
|
+
- "Cns::Bigquery#ethk_1val"
|
|
18
|
+
- "Cns::Bigquery#ethk_2val"
|
|
19
|
+
- "Cns::Bigquery#ethk_3val"
|
|
20
|
+
- "Cns::Bigquery#eost_1val"
|
|
21
|
+
- "Cns::Bigquery#eost_2val"
|
|
22
|
+
- "Cns::Bigquery#det_1val"
|
|
23
|
+
- "Cns::Bigquery#det_2val"
|
|
24
|
+
- "Cns::Bigquery#mtl_1val"
|
|
25
|
+
- "Cns::Bigquery#ust_1val"
|
|
26
|
+
- "Cns::Bigquery#frl_val"
|
|
27
|
+
- "Cns::Bigquery#usl_val"
|
|
28
|
+
- "Cns::Bitcoinde#formata_ledger"
|
|
29
|
+
- "Cns::Bitcoinde#formata_trades"
|
|
30
|
+
- "Cns::Etherscan#bq_bc"
|
|
31
|
+
- "Cns::Etherscan#formata_valores"
|
|
32
|
+
- "Cns::Etherscan#formata_endereco"
|
|
33
|
+
- "Cns::Etherscan#formata_transacao_norml"
|
|
34
|
+
- "Cns::Etherscan#formata_transacao_token"
|
|
35
|
+
- "Cns::Greymass#bq_bc"
|
|
36
|
+
- "Cns::Greymass#greymass_sl"
|
|
37
|
+
- "Cns::Greymass#formata_carteira"
|
|
38
|
+
- "Cns::Greymass#formata_ledger"
|
|
39
|
+
- "Cns::Greymass#filtrar_tx"
|
|
40
|
+
- "Cns::Kraken#formata_ledger"
|
|
41
|
+
- "Cns::Kraken#formata_trades"
|
|
42
|
+
- "Cns::Paymium#formata_ledger"
|
|
43
|
+
- "Cns::Paymium#formata_uuid"
|
|
44
|
+
- "Cns::TheRock#formata_ledger"
|
|
45
|
+
- "Cns::TheRock#formata_saldos"
|
|
46
|
+
UtilityFunction:
|
|
47
|
+
exclude:
|
|
48
|
+
- "Cns::Apice#hus"
|
|
49
|
+
- "Cns::Bigquery#del_val"
|
|
50
|
+
- "Cns::Etherscan#ok?"
|
|
51
|
+
- "Cns::Greymass#ok?"
|
|
52
|
+
NestedIterators:
|
|
53
|
+
exclude:
|
|
54
|
+
- "Cns::Etherscan#idk"
|
|
55
|
+
- "Cns::Etherscan#idt"
|
|
56
|
+
- "Cns::Etherscan#novtx"
|
|
57
|
+
- "Cns::Etherscan#novkx"
|
|
58
|
+
- "Cns::Etherscan#dados"
|
|
59
|
+
- "Cns::Etherscan#filtrar_tx"
|
|
60
|
+
- "Cns::Greymass#novax"
|
|
61
|
+
- "Cns::Greymass#idt"
|
|
62
|
+
- "Cns::Greymass#dados"
|
|
63
|
+
- "Cns::Paymium#kyl"
|
|
64
|
+
- "Cns::Paymium#ledger"
|
data/.rubocop.yml
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
---
|
|
1
2
|
AllCops:
|
|
2
3
|
TargetRubyVersion: 2.7
|
|
3
4
|
EnabledByDefault: true
|
|
4
5
|
|
|
5
6
|
Style/Copyright:
|
|
6
|
-
|
|
7
|
+
Enabled: false
|
|
7
8
|
|
|
8
9
|
Lint/ConstantResolution:
|
|
9
|
-
|
|
10
|
+
Enabled: false
|
|
10
11
|
|
|
11
12
|
Style/ConstantVisibility:
|
|
12
|
-
|
|
13
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cns (0.1.
|
|
4
|
+
cns (0.1.6)
|
|
5
5
|
curb
|
|
6
6
|
faraday
|
|
7
7
|
google-cloud-bigquery
|
|
8
8
|
thor
|
|
9
|
-
yard
|
|
10
9
|
|
|
11
10
|
GEM
|
|
12
11
|
remote: https://rubygems.org/
|
|
13
12
|
specs:
|
|
14
13
|
addressable (2.7.0)
|
|
15
14
|
public_suffix (>= 2.0.2, < 5.0)
|
|
15
|
+
ast (2.4.1)
|
|
16
|
+
backport (1.1.2)
|
|
17
|
+
benchmark (0.1.0)
|
|
16
18
|
concurrent-ruby (1.1.7)
|
|
17
|
-
curb (0.9.
|
|
19
|
+
curb (0.9.11)
|
|
18
20
|
declarative (0.0.20)
|
|
19
21
|
declarative-option (0.1.0)
|
|
20
|
-
|
|
22
|
+
e2mmap (0.1.0)
|
|
23
|
+
faraday (1.1.0)
|
|
21
24
|
multipart-post (>= 1.2, < 3)
|
|
22
|
-
|
|
25
|
+
ruby2_keywords
|
|
26
|
+
google-api-client (0.52.0)
|
|
23
27
|
addressable (~> 2.5, >= 2.5.1)
|
|
24
28
|
googleauth (~> 0.9)
|
|
25
29
|
httpclient (>= 2.8.1, < 3.0)
|
|
@@ -28,19 +32,19 @@ GEM
|
|
|
28
32
|
retriable (>= 2.0, < 4.0)
|
|
29
33
|
rexml
|
|
30
34
|
signet (~> 0.12)
|
|
31
|
-
google-cloud-bigquery (1.
|
|
35
|
+
google-cloud-bigquery (1.25.0)
|
|
32
36
|
concurrent-ruby (~> 1.0)
|
|
33
|
-
google-api-client (~> 0.
|
|
37
|
+
google-api-client (~> 0.47)
|
|
34
38
|
google-cloud-core (~> 1.2)
|
|
35
39
|
googleauth (~> 0.9)
|
|
36
40
|
mini_mime (~> 1.0)
|
|
37
41
|
google-cloud-core (1.5.0)
|
|
38
42
|
google-cloud-env (~> 1.0)
|
|
39
43
|
google-cloud-errors (~> 1.0)
|
|
40
|
-
google-cloud-env (1.
|
|
44
|
+
google-cloud-env (1.4.0)
|
|
41
45
|
faraday (>= 0.17.3, < 2.0)
|
|
42
46
|
google-cloud-errors (1.0.1)
|
|
43
|
-
googleauth (0.
|
|
47
|
+
googleauth (0.14.0)
|
|
44
48
|
faraday (>= 0.17.3, < 2.0)
|
|
45
49
|
jwt (>= 1.4, < 3.0)
|
|
46
50
|
memoist (~> 0.16)
|
|
@@ -48,27 +52,80 @@ GEM
|
|
|
48
52
|
os (>= 0.9, < 2.0)
|
|
49
53
|
signet (~> 0.14)
|
|
50
54
|
httpclient (2.8.3)
|
|
55
|
+
jaro_winkler (1.5.4)
|
|
51
56
|
jwt (2.2.2)
|
|
57
|
+
kramdown (2.3.0)
|
|
58
|
+
rexml
|
|
59
|
+
kramdown-parser-gfm (1.1.0)
|
|
60
|
+
kramdown (~> 2.0)
|
|
61
|
+
kwalify (0.7.2)
|
|
52
62
|
memoist (0.16.2)
|
|
53
63
|
mini_mime (1.0.2)
|
|
64
|
+
mini_portile2 (2.4.0)
|
|
54
65
|
multi_json (1.15.0)
|
|
55
66
|
multipart-post (2.1.1)
|
|
67
|
+
nokogiri (1.10.10)
|
|
68
|
+
mini_portile2 (~> 2.4.0)
|
|
56
69
|
os (1.1.1)
|
|
70
|
+
parallel (1.20.1)
|
|
71
|
+
parser (2.7.2.0)
|
|
72
|
+
ast (~> 2.4.1)
|
|
73
|
+
psych (3.2.1)
|
|
57
74
|
public_suffix (4.0.6)
|
|
75
|
+
rainbow (3.0.0)
|
|
58
76
|
rake (12.3.3)
|
|
77
|
+
reek (6.0.2)
|
|
78
|
+
kwalify (~> 0.7.0)
|
|
79
|
+
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
|
80
|
+
psych (~> 3.1)
|
|
81
|
+
rainbow (>= 2.0, < 4.0)
|
|
82
|
+
regexp_parser (2.0.1)
|
|
59
83
|
representable (3.0.4)
|
|
60
84
|
declarative (< 0.1.0)
|
|
61
85
|
declarative-option (< 0.2.0)
|
|
62
86
|
uber (< 0.2.0)
|
|
63
87
|
retriable (3.1.2)
|
|
88
|
+
reverse_markdown (2.0.0)
|
|
89
|
+
nokogiri
|
|
64
90
|
rexml (3.2.4)
|
|
91
|
+
rubocop (1.6.1)
|
|
92
|
+
parallel (~> 1.10)
|
|
93
|
+
parser (>= 2.7.1.5)
|
|
94
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
95
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
96
|
+
rexml
|
|
97
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
98
|
+
ruby-progressbar (~> 1.7)
|
|
99
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
100
|
+
rubocop-ast (1.3.0)
|
|
101
|
+
parser (>= 2.7.1.5)
|
|
102
|
+
rubocop-rake (0.5.1)
|
|
103
|
+
rubocop
|
|
104
|
+
ruby-progressbar (1.10.1)
|
|
105
|
+
ruby2_keywords (0.0.2)
|
|
65
106
|
signet (0.14.0)
|
|
66
107
|
addressable (~> 2.3)
|
|
67
108
|
faraday (>= 0.17.3, < 2.0)
|
|
68
109
|
jwt (>= 1.5, < 3.0)
|
|
69
110
|
multi_json (~> 1.10)
|
|
111
|
+
solargraph (0.40.0)
|
|
112
|
+
backport (~> 1.1)
|
|
113
|
+
benchmark
|
|
114
|
+
bundler (>= 1.17.2)
|
|
115
|
+
e2mmap
|
|
116
|
+
jaro_winkler (~> 1.5)
|
|
117
|
+
kramdown (~> 2.3)
|
|
118
|
+
kramdown-parser-gfm (~> 1.1)
|
|
119
|
+
parser (~> 2.3)
|
|
120
|
+
reverse_markdown (>= 1.0.5, < 3)
|
|
121
|
+
rubocop (>= 0.52)
|
|
122
|
+
thor (~> 1.0)
|
|
123
|
+
tilt (~> 2.0)
|
|
124
|
+
yard (~> 0.9, >= 0.9.24)
|
|
70
125
|
thor (1.0.1)
|
|
126
|
+
tilt (2.0.10)
|
|
71
127
|
uber (0.1.0)
|
|
128
|
+
unicode-display_width (1.7.0)
|
|
72
129
|
yard (0.9.25)
|
|
73
130
|
|
|
74
131
|
PLATFORMS
|
|
@@ -78,6 +135,11 @@ DEPENDENCIES
|
|
|
78
135
|
bundler
|
|
79
136
|
cns!
|
|
80
137
|
rake (~> 12.0)
|
|
138
|
+
reek
|
|
139
|
+
rubocop
|
|
140
|
+
rubocop-rake
|
|
141
|
+
solargraph
|
|
142
|
+
yard
|
|
81
143
|
|
|
82
144
|
BUNDLED WITH
|
|
83
145
|
2.1.4
|
data/cns.gemspec
CHANGED
|
@@ -7,15 +7,14 @@ Gem::Specification.new do |spec|
|
|
|
7
7
|
spec.version = Cns::VERSION
|
|
8
8
|
spec.authors = ['Hernâni Rodrigues Vaz']
|
|
9
9
|
spec.email = ['hernanirvaz@gmail.com']
|
|
10
|
-
|
|
11
|
-
spec.summary = 'Arquiva transactions etherscan/greymass/bitcoinde/kraken/paymium/therock no bigquery.'
|
|
12
|
-
spec.description = "#{spec.summary} Pode ajustar dias para reposicionamento temporal."
|
|
13
10
|
spec.homepage = 'https://github.com/hernanirvaz/cns'
|
|
14
11
|
spec.license = 'MIT'
|
|
15
|
-
spec.
|
|
12
|
+
spec.summary = 'Arquiva transactions etherscan/greymass/bitcoinde/kraken/paymium/therock no bigquery.'
|
|
13
|
+
spec.description = "#{spec.summary} Pode ajustar dias para reposicionamento temporal."
|
|
16
14
|
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('~> 2.7')
|
|
17
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
-
spec.metadata['yard.run']
|
|
17
|
+
spec.metadata['yard.run'] = 'yard'
|
|
19
18
|
|
|
20
19
|
# Specify which files should be added to the gem when it is released.
|
|
21
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
@@ -29,10 +28,14 @@ Gem::Specification.new do |spec|
|
|
|
29
28
|
|
|
30
29
|
spec.add_development_dependency('bundler')
|
|
31
30
|
spec.add_development_dependency('rake')
|
|
31
|
+
spec.add_development_dependency('reek')
|
|
32
|
+
spec.add_development_dependency('rubocop')
|
|
33
|
+
spec.add_development_dependency('rubocop-rake')
|
|
34
|
+
spec.add_development_dependency('solargraph')
|
|
35
|
+
spec.add_development_dependency('yard')
|
|
32
36
|
|
|
33
37
|
spec.add_dependency('curb')
|
|
34
38
|
spec.add_dependency('faraday')
|
|
35
39
|
spec.add_dependency('google-cloud-bigquery')
|
|
36
40
|
spec.add_dependency('thor')
|
|
37
|
-
spec.add_dependency('yard')
|
|
38
41
|
end
|
data/lib/cns.rb
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require('thor')
|
|
4
|
-
require('cns/
|
|
5
|
-
require('cns/
|
|
6
|
-
require('cns/
|
|
7
|
-
require('cns/apigm')
|
|
8
|
-
require('cns/apimt')
|
|
9
|
-
require('cns/apius')
|
|
4
|
+
require('cns/apibc')
|
|
5
|
+
require('cns/apice1')
|
|
6
|
+
require('cns/apice2')
|
|
10
7
|
require('cns/bigquery1')
|
|
11
8
|
require('cns/bigquery2')
|
|
12
9
|
require('cns/bigquery3')
|
|
13
10
|
require('cns/bigquery4')
|
|
14
|
-
require('cns/bitcoinde')
|
|
15
11
|
require('cns/etherscan1')
|
|
16
12
|
require('cns/etherscan2')
|
|
17
13
|
require('cns/greymass1')
|
|
18
14
|
require('cns/greymass2')
|
|
15
|
+
require('cns/bitcoinde')
|
|
19
16
|
require('cns/kraken')
|
|
20
17
|
require('cns/paymium')
|
|
21
18
|
require('cns/therock')
|
|
22
19
|
require('cns/version')
|
|
23
20
|
|
|
24
21
|
module Cns
|
|
25
|
-
# classe para erros desta gem
|
|
26
|
-
class Erro < StandardError
|
|
27
|
-
# @return [StandardError] personalizacao dos erros
|
|
28
|
-
def initialize(msg)
|
|
29
|
-
super(msg)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
22
|
# classe para carregar/mostrar dados transacoes eth & eos no bigquery
|
|
34
23
|
class CLI < Thor
|
|
35
24
|
desc 'work', 'carrega transacoes novas no bigquery'
|
data/lib/cns/apibc.rb
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('faraday')
|
|
4
|
+
require('json')
|
|
5
|
+
|
|
6
|
+
# @author Hernani Rodrigues Vaz
|
|
7
|
+
module Cns
|
|
8
|
+
# classe para acesso dados blockchains
|
|
9
|
+
class Apibc
|
|
10
|
+
# @example account_es
|
|
11
|
+
# {
|
|
12
|
+
# status: '1',
|
|
13
|
+
# message: 'OK',
|
|
14
|
+
# result: [
|
|
15
|
+
# { account: '0x...', balance: '4000000000000000000' },
|
|
16
|
+
# { account: '0x...', balance: '87000000000000000000' }
|
|
17
|
+
# ]
|
|
18
|
+
# }
|
|
19
|
+
# @param [String] ads lista enderecos ETH (max 20)
|
|
20
|
+
# @return [Array<Hash>] lista enderecos e seus saldos
|
|
21
|
+
def account_es(ads)
|
|
22
|
+
JSON.parse(
|
|
23
|
+
conn_es.get('api', action: 'balancemulti', tag: 'latest', address: ads.join(',')).body,
|
|
24
|
+
symbolize_names: true
|
|
25
|
+
)[:result]
|
|
26
|
+
rescue StandardError
|
|
27
|
+
[]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @example account_gm
|
|
31
|
+
# {
|
|
32
|
+
# account_name: '...',
|
|
33
|
+
# head_block_num: 141_391_122,
|
|
34
|
+
# head_block_time: '2020-09-11T16:05:51.000',
|
|
35
|
+
# privileged: false,
|
|
36
|
+
# last_code_update: '1970-01-01T00:00:00.000',
|
|
37
|
+
# created: '2018-06-09T13:14:37.000',
|
|
38
|
+
#
|
|
39
|
+
# core_liquid_balance: '1232.0228 EOS',
|
|
40
|
+
# total_resources: { owner: '...', net_weight: '1000.1142 EOS', cpu_weight: '1000.1144 EOS', ram_bytes: 8148 },
|
|
41
|
+
#
|
|
42
|
+
# ram_quota: 9548,
|
|
43
|
+
# net_weight: 10_001_142,
|
|
44
|
+
# cpu_weight: 10_001_144,
|
|
45
|
+
# net_limit: { used: 0, available: 1_066_648_346, max: 1_066_648_346 },
|
|
46
|
+
# cpu_limit: { used: 338, available: 88_498, max: 88_836 },
|
|
47
|
+
# ram_usage: 3574,
|
|
48
|
+
# permissions: [
|
|
49
|
+
# {
|
|
50
|
+
# perm_name: 'active',
|
|
51
|
+
# parent: 'owner',
|
|
52
|
+
# required_auth: {
|
|
53
|
+
# threshold: 1, keys: [{ key: 'EOS...', weight: 1 }], accounts: [], waits: []
|
|
54
|
+
# }
|
|
55
|
+
# },
|
|
56
|
+
# {
|
|
57
|
+
# perm_name: 'owner',
|
|
58
|
+
# parent: '',
|
|
59
|
+
# required_auth: {
|
|
60
|
+
# threshold: 1, keys: [{ key: 'EOS...', weight: 1 }], accounts: [], waits: []
|
|
61
|
+
# }
|
|
62
|
+
# }
|
|
63
|
+
# ],
|
|
64
|
+
# self_delegated_bandwidth: { from: '...', to: '...', net_weight: '1000.1142 EOS', cpu_weight: '1000.1144 EOS' },
|
|
65
|
+
# refund_request: nil,
|
|
66
|
+
# voter_info: {
|
|
67
|
+
# owner: '...',
|
|
68
|
+
# proxy: '...',
|
|
69
|
+
# producers: [],
|
|
70
|
+
# staked: 20_002_286,
|
|
71
|
+
# last_vote_weight: '17172913021904.12109375000000000',
|
|
72
|
+
# proxied_vote_weight: '0.00000000000000000',
|
|
73
|
+
# is_proxy: 0,
|
|
74
|
+
# flags1: 0,
|
|
75
|
+
# reserved2: 0,
|
|
76
|
+
# reserved3: '0.0000 EOS'
|
|
77
|
+
# },
|
|
78
|
+
# rex_info: nil
|
|
79
|
+
# }
|
|
80
|
+
# @param [String] add endereco EOS
|
|
81
|
+
# @return [Hash] endereco e seus saldo/recursos
|
|
82
|
+
def account_gm(add)
|
|
83
|
+
JSON.parse(conn_gm.post('/v1/chain/get_account', { account_name: add }.to_json).body, symbolize_names: true)
|
|
84
|
+
rescue StandardError
|
|
85
|
+
{ core_liquid_balance: 0, total_resources: { net_weight: 0, cpu_weight: 0 } }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# @example norml_es
|
|
89
|
+
# {
|
|
90
|
+
# status: '1',
|
|
91
|
+
# message: 'OK',
|
|
92
|
+
# result: [
|
|
93
|
+
# {
|
|
94
|
+
# blockNumber: '4984535',
|
|
95
|
+
# timeStamp: '1517094794',
|
|
96
|
+
# hash: '0x...',
|
|
97
|
+
# nonce: '10',
|
|
98
|
+
# blockHash: '0x...',
|
|
99
|
+
# transactionIndex: '17',
|
|
100
|
+
# from: '0x...',
|
|
101
|
+
# to: '0x...',
|
|
102
|
+
# value: '52627271000000000000',
|
|
103
|
+
# gas: '21000',
|
|
104
|
+
# gasPrice: '19000000000',
|
|
105
|
+
# isError: '0',
|
|
106
|
+
# txreceipt_status: '1',
|
|
107
|
+
# input: '0x',
|
|
108
|
+
# contractAddress: '',
|
|
109
|
+
# gasUsed: '21000',
|
|
110
|
+
# cumulativeGasUsed: '566293',
|
|
111
|
+
# confirmations: '5848660'
|
|
112
|
+
# },
|
|
113
|
+
# {}
|
|
114
|
+
# ]
|
|
115
|
+
# }
|
|
116
|
+
# @param [String] add endereco ETH
|
|
117
|
+
# @param [Integer] pag pagina transacoes
|
|
118
|
+
# @param [Array<Hash>] aes acumulador transacoes
|
|
119
|
+
# @return [Array<Hash>] lista completa transacoes etherscan
|
|
120
|
+
def norml_es(add, pag = 0, aes = [])
|
|
121
|
+
res = JSON.parse(
|
|
122
|
+
conn_es.get('api', action: 'txlist', offset: 10_000, address: add, page: pag += 1).body,
|
|
123
|
+
symbolize_names: true
|
|
124
|
+
)[:result]
|
|
125
|
+
aes += res
|
|
126
|
+
res.count < 10_000 ? aes : norml_es(add, pag, aes)
|
|
127
|
+
rescue StandardError
|
|
128
|
+
aes
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# @example token_es
|
|
132
|
+
# {
|
|
133
|
+
# status: '1',
|
|
134
|
+
# message: 'OK',
|
|
135
|
+
# result: [
|
|
136
|
+
# {
|
|
137
|
+
# blockNumber: '3967652',
|
|
138
|
+
# timeStamp: '1499081515',
|
|
139
|
+
# hash: '0x registo duplicado com todos os dados iguais',
|
|
140
|
+
# nonce: '3',
|
|
141
|
+
# blockHash: '0x00a49e999036dc13dc6c4244bb1d51d3146fe7f00bfb500a7624d82e299c7328',
|
|
142
|
+
# from: '0xd0a6e6c54dbc68db5db3a091b171a77407ff7ccf',
|
|
143
|
+
# contractAddress: '0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0',
|
|
144
|
+
# to: '0x...',
|
|
145
|
+
# value: '0',
|
|
146
|
+
# tokenName: 'EOS',
|
|
147
|
+
# tokenSymbol: 'EOS',
|
|
148
|
+
# tokenDecimal: '18',
|
|
149
|
+
# transactionIndex: '83',
|
|
150
|
+
# gas: '173399',
|
|
151
|
+
# gasPrice: '21000000000',
|
|
152
|
+
# gasUsed: '173398',
|
|
153
|
+
# input: 'deprecated',
|
|
154
|
+
# cumulativeGasUsed: '7484878',
|
|
155
|
+
# confirmations: '3442641'
|
|
156
|
+
# },
|
|
157
|
+
# {}
|
|
158
|
+
# ]
|
|
159
|
+
# }
|
|
160
|
+
# @param (see norml_es)
|
|
161
|
+
# @return [Array<Hash>] lista completa token transfer events etherscan
|
|
162
|
+
def token_es(add, pag = 0, aes = [])
|
|
163
|
+
# registos duplicados aparecem em token events (ver exemplo acima)
|
|
164
|
+
# -quando ha erros na blockchain (acho)
|
|
165
|
+
# -quando ha token events identicos no mesmo block (acho)
|
|
166
|
+
res = JSON.parse(
|
|
167
|
+
conn_es.get('api', action: 'tokentx', offset: 10_000, address: add, page: pag += 1).body,
|
|
168
|
+
symbolize_names: true
|
|
169
|
+
)[:result]
|
|
170
|
+
aes += res
|
|
171
|
+
res.count < 10_000 ? aes : token_es(add, pag, aes)
|
|
172
|
+
rescue StandardError
|
|
173
|
+
aes
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# @example ledger_gm
|
|
177
|
+
# {
|
|
178
|
+
# actions: [
|
|
179
|
+
# {
|
|
180
|
+
# account_action_seq: 964,
|
|
181
|
+
# action_trace: {
|
|
182
|
+
# account_ram_deltas: [],
|
|
183
|
+
# act: {
|
|
184
|
+
# account: 'voicebestapp',
|
|
185
|
+
# authorization: [
|
|
186
|
+
# { actor: 'thetruevoice', permission: 'active' },
|
|
187
|
+
# { actor: 'voicebestapp', permission: 'active' }
|
|
188
|
+
# ],
|
|
189
|
+
# data: { from: 'voicebestapp', memo: '...', quantity: '1.0001 MESSAGE', to: '...' },
|
|
190
|
+
# hex_data: '...',
|
|
191
|
+
# name: 'transfer'
|
|
192
|
+
# },
|
|
193
|
+
# action_ordinal: 10,
|
|
194
|
+
# block_num: 141_345_345,
|
|
195
|
+
# block_time: '2020-09-11T09:44:04.500',
|
|
196
|
+
# closest_unnotified_ancestor_action_ordinal: 5,
|
|
197
|
+
# context_free: false,
|
|
198
|
+
# creator_action_ordinal: 5,
|
|
199
|
+
# elapsed: 6,
|
|
200
|
+
# producer_block_id: '...',
|
|
201
|
+
# receipt: {
|
|
202
|
+
# abi_sequence: 1,
|
|
203
|
+
# act_digest: '...',
|
|
204
|
+
# auth_sequence: [['thetruevoice', 6_778_215], ['voicebestapp', 435_346]],
|
|
205
|
+
# code_sequence: 1,
|
|
206
|
+
# global_sequence: 233_283_589_258,
|
|
207
|
+
# receiver: '...',
|
|
208
|
+
# recv_sequence: 927
|
|
209
|
+
# },
|
|
210
|
+
# receiver: '...',
|
|
211
|
+
# trx_id: '...'
|
|
212
|
+
# },
|
|
213
|
+
# block_num: 141_345_345,
|
|
214
|
+
# block_time: '2020-09-11T09:44:04.500',
|
|
215
|
+
# global_action_seq: 233_283_589_258,
|
|
216
|
+
# irreversible: true
|
|
217
|
+
# },
|
|
218
|
+
# {}
|
|
219
|
+
# ],
|
|
220
|
+
# head_block_num: 141_721_698,
|
|
221
|
+
# last_irreversible_block: 141_721_371
|
|
222
|
+
# }
|
|
223
|
+
# @param add (see account_gm)
|
|
224
|
+
# @param [Array<Hash>] agm acumulador transacoes
|
|
225
|
+
# @return [Array<Hash>] lista completa transacoes greymass
|
|
226
|
+
def ledger_gm(add, agm = [])
|
|
227
|
+
res = JSON.parse(
|
|
228
|
+
conn_gm.post('/v1/history/get_actions', { account_name: add, pos: agm.count, offset: 100 }.to_json).body,
|
|
229
|
+
symbolize_names: true
|
|
230
|
+
)[:actions]
|
|
231
|
+
agm += res
|
|
232
|
+
res.count < 100 ? agm : ledger_gm(add, agm)
|
|
233
|
+
rescue StandardError
|
|
234
|
+
agm
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
private
|
|
238
|
+
|
|
239
|
+
# @return [<Symbol>] adapter for the connection - default :net_http
|
|
240
|
+
def adapter
|
|
241
|
+
@adapter ||= Faraday.default_adapter
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# @return [<Faraday::Connection>] connection object for etherscan
|
|
245
|
+
def conn_es
|
|
246
|
+
@conn_es ||=
|
|
247
|
+
Faraday.new(
|
|
248
|
+
url: 'https://api.etherscan.io/',
|
|
249
|
+
params: { module: 'account', apikey: ENV['ETHERSCAN_API_KEY'] },
|
|
250
|
+
headers: { content_type: 'application/json', accept: 'application/json', user_agent: 'etherscan;ruby' }
|
|
251
|
+
) do |con|
|
|
252
|
+
con.request(:url_encoded)
|
|
253
|
+
con.adapter(adapter)
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# @return [<Faraday::Connection>] connection object for greymass
|
|
258
|
+
def conn_gm
|
|
259
|
+
@conn_gm ||=
|
|
260
|
+
Faraday.new(url: 'https://eos.greymass.com', headers: { content_type: 'application/json' }) do |con|
|
|
261
|
+
con.request(:url_encoded)
|
|
262
|
+
con.adapter(adapter)
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
end
|