Skip to content

Commit 66431c0

Browse files
committed
Add submit content format script
1 parent 586ba83 commit 66431c0

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gem "eth"

Gemfile.lock

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
digest-sha3 (1.1.0)
5+
eth (0.4.6)
6+
digest-sha3 (~> 1.1)
7+
ffi (~> 1.0)
8+
money-tree (~> 0.9)
9+
rlp (~> 0.7.3)
10+
scrypt (~> 3.0.5)
11+
ffi (1.9.23)
12+
ffi-compiler (1.0.1)
13+
ffi (>= 1.0.0)
14+
rake
15+
money-tree (0.9.0)
16+
ffi
17+
rake (12.3.1)
18+
rlp (0.7.3)
19+
scrypt (3.0.5)
20+
ffi-compiler (>= 1.0, < 2.0)
21+
22+
PLATFORMS
23+
ruby
24+
25+
DEPENDENCIES
26+
eth
27+
28+
BUNDLED WITH
29+
1.16.1

format.rb

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require "eth"
2+
require "json"
3+
4+
workdir = Dir.pwd
5+
6+
Dir.each_child("erc20") do |file|
7+
next if file == "$template.json" || !file.end_with?("json")
8+
puts "processing file:#{file}"
9+
fullpath = "#{workdir}/erc20/#{file}"
10+
begin
11+
json = JSON.parse IO.read(fullpath)
12+
rescue => e
13+
puts e.message
14+
exit false
15+
end
16+
address_text = json["address"]
17+
downcase_address = address_text.downcase
18+
checksum_address = Eth::Utils.format_address address_text
19+
20+
if address_text != checksum_address
21+
puts "rewrite file:#{file}"
22+
json["address"] = checksum_address
23+
File.open(fullpath, 'w') {|f| f.write JSON.pretty_generate(json, indent: " "*4) }
24+
end
25+
26+
img = "#{workdir}/images/#{downcase_address}.png"
27+
if File.exists?(img)
28+
puts "rewrite image:#{file}"
29+
File.rename(img, "#{workdir}/images/#{checksum_address}.png")
30+
end
31+
end

0 commit comments

Comments
 (0)