Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
substrate-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xx network
substrate-utils
Commits
711c45b5
Commit
711c45b5
authored
3 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Add vesting scheduler json to csv converter
parent
f5d17586
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
convert_vesting_schedule.py
+53
-0
53 additions, 0 deletions
convert_vesting_schedule.py
dump_all_balances.py
+1
-1
1 addition, 1 deletion
dump_all_balances.py
query.py
+18
-0
18 additions, 0 deletions
query.py
with
72 additions
and
1 deletion
convert_vesting_schedule.py
0 → 100644
+
53
−
0
View file @
711c45b5
import
json
q
=
json
.
load
(
open
(
'
query-claims.json
'
,
'
rb
'
))
out
=
open
(
'
out.csv
'
,
'
w
'
)
#print(f"account_id, l1, l2, round_num, days", file=out)
calc_lockups
=
[]
for
account_id
,
lockups
in
q
.
items
():
for
lockup
in
lockups
:
l1
=
lockup
[
0
]
l2
=
lockup
[
1
]
round_num
=
lockup
[
2
]
# *[roundtime] / num_seconds_in_minute / num_minutes_in_hr / num_hrs_in_day
days
=
round_num
*
6
/
60
/
60
/
24
# print(f"{account_id}, {l1}, {l2}, {round_num}, {days}", file=out)
calc_lockups
.
append
({
'
account_id
'
:
account_id
,
'
l1
'
:
l1
,
'
l2
'
:
l2
,
'
round_num
'
:
round_num
,
'
days
'
:
days
,
})
daynames
=
[]
for
cl
in
calc_lockups
:
if
cl
[
'
days
'
]
not
in
daynames
:
daynames
.
append
(
cl
[
'
days
'
])
colnames
=
sorted
(
daynames
)
colnames
.
insert
(
0
,
'
account_id
'
)
print
(
colnames
)
import
csv
rows
=
dict
()
for
cl
in
calc_lockups
:
aid
=
cl
[
'
account_id
'
]
if
aid
not
in
rows
:
rows
[
aid
]
=
{
'
account_id
'
:
aid
,
}
for
col
in
colnames
[
1
:]:
if
col
not
in
rows
[
aid
]:
rows
[
aid
][
col
]
=
0
if
cl
[
'
days
'
]
==
col
:
rows
[
aid
][
col
]
=
cl
[
'
l1
'
]
out
=
csv
.
writer
(
open
(
'
out.csv
'
,
'
w
'
),
delimiter
=
'
,
'
)
out
.
writerow
(
colnames
)
for
_
,
r
in
rows
.
items
():
out
.
writerow
([
x
for
x
in
r
.
values
()])
This diff is collapsed.
Click to expand it.
dump_all_balances.py
+
1
−
1
View file @
711c45b5
...
...
@@ -25,7 +25,7 @@ def main(url, output):
substrate
=
SubstrateInterface
(
url
=
url
)
account_len
=
0
result
=
substrate
.
query_map
(
'
System
'
,
'
Account
'
,
page_size
=
200
,
max_results
=
4
00
)
max_results
=
1000
00
)
out
=
csv
.
writer
(
output
,
delimiter
=
'
,
'
)
headers
=
False
for
account
,
account_info
in
result
:
...
...
This diff is collapsed.
Click to expand it.
query.py
+
18
−
0
View file @
711c45b5
...
...
@@ -2,6 +2,7 @@ import json
import
logging
as
log
import
argparse
from
json
import
JSONDecodeError
import
csv
from
substrateinterface
import
SubstrateInterface
# pip3 install substrate-interface
########################################################################################################################
# Auxiliar Functions
...
...
@@ -161,5 +162,22 @@ def main():
file
.
write
(
json
.
dumps
(
result
,
indent
=
4
))
else
:
print
(
json
.
dumps
(
result
,
indent
=
4
))
out
=
csv
.
writer
(
open
(
'
out.csv
'
,
'
w
'
),
delimiter
=
'
,
'
)
headers
=
False
for
k
,
v
in
result
.
items
():
r
=
[
k
]
if
type
(
v
)
is
dict
:
if
not
headers
:
headers
=
True
r
=
[
"
account_id
"
]
r
.
extend
([
x
for
x
in
v
.
keys
()])
out
.
writerow
(
r
)
r
=
[
k
]
r
.
extend
([
x
for
x
in
v
.
values
()])
else
:
r
=
[
k
,
v
]
out
.
writerow
(
r
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment