forked from consenlabs/token-profile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format.rb
31 lines (27 loc) · 843 Bytes
/
format.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require "eth"
require "json"
workdir = Dir.pwd
Dir.each_child("erc20") do |file|
next if file == "$template.json" || !file.end_with?("json")
puts "processing file:#{file}"
fullpath = "#{workdir}/erc20/#{file}"
begin
json = JSON.parse IO.read(fullpath)
rescue => e
puts e.message
exit false
end
address_text = json["address"]
downcase_address = address_text.downcase
checksum_address = Eth::Utils.format_address address_text
if address_text != checksum_address
puts "rewrite file:#{file}"
json["address"] = checksum_address
File.open(fullpath, 'w') {|f| f.write JSON.pretty_generate(json, indent: " "*4) }
end
img = "#{workdir}/images/#{downcase_address}.png"
if File.exists?(img)
puts "rewrite image:#{file}"
File.rename(img, "#{workdir}/images/#{checksum_address}.png")
end
end