-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
336 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
address, names, interfaces, created | ||
0x22a81c80bb6bf4b797acf08351934b46193bddde, novo | novo punks, , 2023-01-08 04:10:59 | ||
0x897792d16a46f9e70446638bfc6a0d884b741f9b, pepe burb punks, , 2023-01-10 13:36:47 | ||
0x0e10e5e978ba4d1af92eb554cd730c9b97f4e571, pepe blocks, , 2023-01-14 05:37:35 | ||
0x5a8e04a84fb2f6ad4002c824045c7c1bde10cb81, frog central, , 2023-01-17 03:42:35 | ||
0xe302f509c4a3729791215f74299f1fa626396e5a, gm kevin, , 2023-01-19 00:24:35 | ||
0xcce158dd5384b599fc29fe34d83b11ea8fb7a816, death of kevin, , 2023-01-22 12:09:47 | ||
0xb0dc51536e2b4950d7d6667748a6be6fc53c3318, cute kevin, , 2023-01-22 16:29:35 | ||
0x94cb646dd34b3b0ff7c116208f7f7ff7ac216079, ecc0s, , 2023-01-25 12:38:11 | ||
0xe6313d1776e4043d906d5b7221be70cf470f5e87, shiba, , 2023-01-26 02:20:47 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
$LOAD_PATH.unshift( "../etherscan-lite/lib" ) | ||
|
||
require 'ethname' | ||
require 'etherscan-lite' | ||
|
||
puts " #{Ethname.directory.size} (contract) address record(s)" | ||
|
||
|
||
|
||
class ContractDetailsCache | ||
|
||
def initialize( path ) | ||
@path = path | ||
@table = if File.exist?( path ) | ||
build_table( read_csv( path ) ) | ||
else | ||
{} | ||
end | ||
end | ||
|
||
def [](addr) | ||
if @table.has_key?( addr ) | ||
@table[ addr ] | ||
else ## fetch missing data | ||
data = Etherscan.getcontractdetails( contractaddress: addr ) | ||
## note: add new data to cache | ||
@table[ addr ] = data | ||
data | ||
end | ||
end | ||
|
||
|
||
|
||
def build_table( recs ) | ||
h = {} | ||
recs.each do |rec| | ||
## (re)use contractdetails format / hash keys | ||
h[ rec['address'] ] = { | ||
'contractAddress' => rec['address'], | ||
'contractCreator' => rec['creator'], | ||
'txHash' => rec['txid'], | ||
'blockNumber' => rec['blocknumber'], | ||
'timestamp' => rec['timestamp'] | ||
} | ||
end | ||
h | ||
end | ||
|
||
def save | ||
############## | ||
## save cache - sort by blocknumber | ||
entries = @table.values.sort { |l,r| l['blockNumber'].to_i(16) <=> r['blockNumber'].to_i(16) } | ||
buf = '' | ||
buf << ['blocknumber', 'timestamp', 'address', 'creator', 'txid'].join( ', ' ) | ||
buf << "\n" | ||
entries.each do |entry| | ||
buf << [entry['blockNumber'], | ||
entry['timestamp'], | ||
entry['contractAddress'], | ||
entry['contractCreator'], | ||
entry['txHash'] | ||
].join( ', ' ) | ||
buf << "\n" | ||
end | ||
write_text( @path, buf ) | ||
end | ||
end # class ContractDetailsCache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
names, address | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
## | ||
# check and auto-fill new contract candidates in inbox | ||
# | ||
# to run use | ||
# ruby -I ./lib sandbox/inbox.rb | ||
|
||
|
||
require_relative 'helper' | ||
|
||
## step 1: | ||
## collect more metadata about (contract) address | ||
|
||
## build cache | ||
cache = ContractDetailsCache.new( './sandbox/contractdetails.csv' ) | ||
|
||
|
||
meta = [] | ||
|
||
recs = read_csv( './sandbox/inbox.csv' ) | ||
puts " #{recs.size} record(s)" | ||
|
||
recs.each_with_index do |rec,i| | ||
names = rec['names'] | ||
addr = rec['address'].downcase | ||
puts "==> [#{i+1}] #{names} @ #{addr}..." | ||
|
||
data = cache[ addr ] | ||
pp data | ||
|
||
timestamp = data['timestamp'].to_i(16) | ||
|
||
## reformat to "classic format" | ||
## for date use "2022-02-03 08:49:52" | ||
meta << [addr, names, '', | ||
Time.at( timestamp ).utc.strftime( '%Y-%m-%d %H:%M:%S' ) | ||
] | ||
end | ||
|
||
### note: save back contractdetails cache | ||
cache.save | ||
|
||
|
||
## (re)sort by timestamp / created date | ||
meta = meta.sort { |l,r| l[3] <=> r[3] } | ||
|
||
|
||
## tddo - lint / warn about non-unique names if any!!! | ||
## todo - keep track of duplicate in new names too!!! | ||
|
||
|
||
pp meta | ||
|
||
|
||
meta.each do |values| | ||
names = values[1] | ||
rec = Ethname[ names ] | ||
if rec | ||
puts "!! WARN - duplicate contract found for >#{names}<:" | ||
pp rec | ||
end | ||
end | ||
|
||
|
||
headers = [ | ||
'address', | ||
'names', | ||
'interfaces', | ||
'created' | ||
] | ||
### | ||
|
||
|
||
buf = String.new('') | ||
buf << headers.join( ', ') | ||
buf << "\n" | ||
meta.each do |values| | ||
buf << values.join( ', ' ) | ||
buf << "\n" | ||
end | ||
|
||
|
||
write_text( "./tmp/contracts.csv", buf ) | ||
|
||
puts "bye" | ||
|
||
__END__ | ||
|
||
|
||
[["0x22a81c80bb6bf4b797acf08351934b46193bddde", "novo", "", "2023-01-08 04:10:59 UTC"], | ||
["0x897792d16a46f9e70446638bfc6a0d884b741f9b", "pepeburbpunks", "", "2023-01-10 13:36:47 UTC"], | ||
["0x0e10e5e978ba4d1af92eb554cd730c9b97f4e571", "pepeblocks", "", "2023-01-14 05:37:35 UTC"], | ||
["0x5a8e04a84fb2f6ad4002c824045c7c1bde10cb81", "frogcentral", "", "2023-01-17 03:42:35 UTC"], | ||
["0xe302f509c4a3729791215f74299f1fa626396e5a", "gmkevin", "", "2023-01-19 00:24:35 UTC"], | ||
["0xcce158dd5384b599fc29fe34d83b11ea8fb7a816", "deathofkevin", "", "2023-01-22 12:09:47 UTC"], | ||
["0xb0dc51536e2b4950d7d6667748a6be6fc53c3318", "cutekevin", "", "2023-01-22 16:29:35 UTC"], | ||
["0x94cb646dd34b3b0ff7c116208f7f7ff7ac216079", "ecc0s", "", "2023-01-25 12:38:11 UTC"], | ||
["0xe6313d1776e4043d906d5b7221be70cf470f5e87", "shiba", "", "2023-01-26 02:20:47 UTC"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.