ethname 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Manifest.txt +10 -0
- data/README.md +110 -0
- data/Rakefile +32 -0
- data/config/contracts.2017.csv +6 -0
- data/config/contracts.2021.csv +11 -0
- data/config/contracts.2022.csv +15 -0
- data/lib/ethname/dictionary.rb +75 -0
- data/lib/ethname/version.rb +22 -0
- data/lib/ethname.rb +30 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 450342f14ab626b337ad859811381f4185a11cfd805a887fb628be35427c6549
|
4
|
+
data.tar.gz: 45b92de48f56083fad1e94975f1dfb58f7afeb4d64ee55a12650104ae87372af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e37ff7f85701c927c9f5fb8f78b8174b003f7a521f1e6d705c565f919f1d437d5b467ac044484379a45be52669de8cb427b45cf4f3c02b31c75fa313c1eddbc
|
7
|
+
data.tar.gz: 0bcee46cf8ebb0b33de5e85c9ce93e7fc9b1dd33a40a6a771b92d99943362ef4758db0d9a022d838bdcbfdc127c8ce9fc33ab4e81233aff0ed7c43f50e0755bc
|
data/CHANGELOG.md
ADDED
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Ethname - Free Crowd-Sourced "Off-Chain" Eth(erum) Name Service
|
2
|
+
|
3
|
+
ethname - light-weight crowd-sourced "off-chain" ethereum name to (contract) address service / helper (incl. punks v1,v2,v3,v4; phunks v1,v2, synth punks, punk blocks, etc.) - yes, you can! - add more names / contracts via git ;-)
|
4
|
+
|
5
|
+
|
6
|
+
* home :: [github.com/rubycocos/blockchain](https://github.com/rubycocos/blockchain)
|
7
|
+
* bugs :: [github.com/rubycocos/blockchain/issues](https://github.com/rubycocos/blockchain/issues)
|
8
|
+
* gem :: [rubygems.org/gems/ethname](https://rubygems.org/gems/ethname)
|
9
|
+
* rdoc :: [rubydoc.info/gems/ethname](http://rubydoc.info/gems/ethname)
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
|
17
|
+
Lookup (contract) addresses by name via the `Ethname` helper:
|
18
|
+
|
19
|
+
``` ruby
|
20
|
+
require 'ethname'
|
21
|
+
|
22
|
+
## let's try some punk (pixel art collection) contracts / services:
|
23
|
+
Ethname['punks v1'] #=> "0x6ba6f2207e343923ba692e5cae646fb0f566db8d"
|
24
|
+
Ethname['punks v2'] #=> "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb"
|
25
|
+
Ethname['punks v3'] #=> "0xd33c078c2486b7be0f7b4dda9b14f35163b949e0"
|
26
|
+
Ethname['punks v4'] #=> "0xd12882c8b5d1bccca57c994c6af7d96355590dbd"
|
27
|
+
|
28
|
+
Ethname['punks v1 wrapped i'] #=> "0xf4a4644e818c2843ba0aabea93af6c80b5984114"
|
29
|
+
Ethname['punks v1 wrapped ii'] #=> "0x282bdd42f4eb70e7a9d9f40c8fea0825b7f68c5d"
|
30
|
+
|
31
|
+
Ethname['phunks v1'] #=> "0xa82f3a61f002f83eba7d184c50bb2a8b359ca1ce"
|
32
|
+
Ethname['phunks v2'] #=> "0xf07468ead8cf26c752c676e43c814fee9c8cf402"
|
33
|
+
Ethname['phunks v3'] #=> "0xa19f0378a6f3f3361d8e962f3589ec28f4f8f159"
|
34
|
+
|
35
|
+
Ethname['synth punks'] #=> "0xaf9ce4b327a3b690abea6f78eccbfefffbea9fdf"
|
36
|
+
|
37
|
+
Ethname['punks data'] #=> "0x16f5a35647d6f03d5d3da7b35409d65ba03af3b2"
|
38
|
+
Ethname['punk blocks'] #=> "0x58e90596c2065befd3060767736c829c18f3474c"
|
39
|
+
|
40
|
+
# and so on
|
41
|
+
```
|
42
|
+
|
43
|
+
Note: The names internally get "normalized", that is,
|
44
|
+
all characters except a-z and the digits 0-9 get stripped
|
45
|
+
that includes spaces, dots (.), dashes (-), underline (_), and so on.
|
46
|
+
Yes, for the lookup you can use all variants of uppercase (PUNKS)
|
47
|
+
or lowercase (punks) spellings. Example:
|
48
|
+
|
49
|
+
|
50
|
+
``` ruby
|
51
|
+
Ethname['Synth Punks'] #=> "0xaf9ce4b327a3b690abea6f78eccbfefffbea9fdf"
|
52
|
+
Ethname['SynthPunks'] #=> "0xaf9ce4b327a3b690abea6f78eccbfefffbea9fdf"
|
53
|
+
Ethname['Synthpunks'] #=> "0xaf9ce4b327a3b690abea6f78eccbfefffbea9fdf"
|
54
|
+
Ethname['SYNTH PUNKS'] #=> "0xaf9ce4b327a3b690abea6f78eccbfefffbea9fdf"
|
55
|
+
Ethname['SYNTHPUNKS'] #=> "0xaf9ce4b327a3b690abea6f78eccbfefffbea9fdf"
|
56
|
+
# and so on
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
## Inside the Crowd-Sourced "Off-Chain" Ethereum Name To (Contract) Address Service
|
62
|
+
|
63
|
+
The name to address mappings are fow now stored
|
64
|
+
in datafiles in the comma-separated value (.csv) format
|
65
|
+
and split by year (e.g. 2017, 2018, ..., 2021, 2022, 2023, etc.)
|
66
|
+
|
67
|
+
Example - [config/contracts.2017.csv](config/contracts.2017.csv):
|
68
|
+
|
69
|
+
``` csv
|
70
|
+
address, names
|
71
|
+
0x6Ba6f2207e343923BA692e5Cae646Fb0F566DB8D, punks v1 | crypto punks v1
|
72
|
+
0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb, punks v2 | crypto punks v2 | crypto punks market
|
73
|
+
0x60cd862c9c687a9de49aecdc3a99b74a4fc54ab6, mooncats | mooncatrescue
|
74
|
+
...
|
75
|
+
```
|
76
|
+
|
77
|
+
Example - [config/contracts.2022.csv](config/contracts.2022.csv):
|
78
|
+
|
79
|
+
``` csv
|
80
|
+
address, names
|
81
|
+
0x282bdd42f4eb70e7a9d9f40c8fea0825b7f68c5d, punks v1 wrapped ii
|
82
|
+
0xD33c078C2486B7Be0F7B4DDa9B14F35163B949e0, punks v3
|
83
|
+
0xd12882c8b5d1bccca57c994c6af7d96355590dbd, punks v4
|
84
|
+
0xA19f0378A6F3f3361d8e962F3589Ec28f4f8F159, phunks v3
|
85
|
+
0xaf9CE4B327A3b690ABEA6F78eCCBfeFFfbEa9FDf, synthetic punks | synth punks
|
86
|
+
0x58E90596C2065BEfD3060767736C829C18F3474c, punk blocks
|
87
|
+
0x23581767a106ae21c074b2276D25e5C3e136a68b, moonbirds
|
88
|
+
...
|
89
|
+
```
|
90
|
+
|
91
|
+
### Yes, You Can! - Add More Names / Contracts Via Git ;-)
|
92
|
+
|
93
|
+
Your contributions welcome. You are welcome to join in and
|
94
|
+
help to add more name to ethereum contract / service mappings.
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
## License
|
100
|
+
|
101
|
+
The scripts are dedicated to the public domain.
|
102
|
+
Use it as you please with no restrictions whatsoever.
|
103
|
+
|
104
|
+
|
105
|
+
## Questions? Comments?
|
106
|
+
|
107
|
+
|
108
|
+
Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
|
109
|
+
|
110
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/ethname/version.rb'
|
3
|
+
|
4
|
+
|
5
|
+
Hoe.spec 'ethname' do
|
6
|
+
|
7
|
+
self.version = Ethname::VERSION
|
8
|
+
|
9
|
+
self.summary = 'ethname - light-weight crowd-sourced "off-chain" ethereum name to (contract) address service / helper (incl. punks v1,v2,v3,v4; phunks v1,v2, synth punks, punk blocks, etc.) - yes, you can! - add more names / contracts via git ;-)'
|
10
|
+
self.description = summary
|
11
|
+
|
12
|
+
self.urls = { home: 'https://github.com/rubycocos/blockchain' }
|
13
|
+
|
14
|
+
self.author = 'Gerald Bauer'
|
15
|
+
self.email = 'wwwmake@googlegroups.com'
|
16
|
+
|
17
|
+
# switch extension to .markdown for gihub formatting
|
18
|
+
self.readme_file = 'README.md'
|
19
|
+
self.history_file = 'CHANGELOG.md'
|
20
|
+
|
21
|
+
self.extra_deps = [
|
22
|
+
['cocos'],
|
23
|
+
]
|
24
|
+
|
25
|
+
self.licenses = ['Public Domain']
|
26
|
+
|
27
|
+
self.spec_extras = {
|
28
|
+
required_ruby_version: '>= 2.3'
|
29
|
+
}
|
30
|
+
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
address, names
|
2
|
+
0x16f5a35647d6f03d5d3da7b35409d65ba03af3b2, punks data | crypto punks data
|
3
|
+
0xf4a4644e818c2843ba0aabea93af6c80b5984114, punks v1 wrapped i | classic punks
|
4
|
+
|
5
|
+
0xa82f3a61f002f83eba7d184c50bb2a8b359ca1ce, phunks v1 | philips
|
6
|
+
0xf07468ead8cf26c752c676e43c814fee9c8cf402, phunks v2 | phunks
|
7
|
+
|
8
|
+
0x031920cc2d9f5c10b444fd44009cd64f829e7be2, zunks
|
9
|
+
|
10
|
+
0x0d0167a823c6619d430b1a96ad85b888bcf97c37, xpunks | expansion punks
|
11
|
+
0x71eb5c179ceb640160853144cbb8df5bd24ab5cc, xphunks | expansion phunks
|
@@ -0,0 +1,15 @@
|
|
1
|
+
address, names
|
2
|
+
0x282bdd42f4eb70e7a9d9f40c8fea0825b7f68c5d, punks v1 wrapped ii
|
3
|
+
|
4
|
+
0xD33c078C2486B7Be0F7B4DDa9B14F35163B949e0, punks v3
|
5
|
+
0xd12882c8b5d1bccca57c994c6af7d96355590dbd, punks v4
|
6
|
+
|
7
|
+
0xA19f0378A6F3f3361d8e962F3589Ec28f4f8F159, phunks v3
|
8
|
+
|
9
|
+
|
10
|
+
0xaf9CE4B327A3b690ABEA6F78eCCBfeFFfbEa9FDf, synthetic punks | synth punks
|
11
|
+
|
12
|
+
0x58E90596C2065BEfD3060767736C829C18F3474c, punk blocks
|
13
|
+
|
14
|
+
|
15
|
+
0x23581767a106ae21c074b2276D25e5C3e136a68b, moonbirds
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
module Ethname
|
3
|
+
|
4
|
+
class Dictionary
|
5
|
+
## let's you lookup up ethereum addresses by name
|
6
|
+
|
7
|
+
def self.read( *paths ) ## use load - why? why not?
|
8
|
+
dict = new
|
9
|
+
paths.each do |path|
|
10
|
+
recs = read_csv( path )
|
11
|
+
dict.add_recs( recs )
|
12
|
+
end
|
13
|
+
dict
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@recs = []
|
20
|
+
@reverse_table = {} ## lookup (address) by (normalized) name
|
21
|
+
end
|
22
|
+
|
23
|
+
def recs() @recs; end
|
24
|
+
def size() @recs.size; end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
def lookup( q )
|
29
|
+
key = normalize( q )
|
30
|
+
addr = @reverse_table[ key ]
|
31
|
+
addr
|
32
|
+
end
|
33
|
+
alias_method :[], :lookup
|
34
|
+
|
35
|
+
|
36
|
+
def add_recs( recs )
|
37
|
+
recs.each do |rec|
|
38
|
+
## note: always downcase addresses for now
|
39
|
+
## (do NOT use addresss checksum with mixed-hexchars) - why? why not?
|
40
|
+
addr = rec['address'].downcase
|
41
|
+
names = rec['names'].split('|')
|
42
|
+
names.each do |name|
|
43
|
+
_add( addr, name )
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
@recs += recs
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
#################
|
52
|
+
# convencience helpers
|
53
|
+
def self.normalize( str )
|
54
|
+
## remove all non a-z (and 0-9) characters
|
55
|
+
str.downcase.gsub( /[^a-z0-9]/i, '' )
|
56
|
+
end
|
57
|
+
|
58
|
+
def normalize( str ) self.class.normalize( str ); end
|
59
|
+
|
60
|
+
####
|
61
|
+
# private (internal) helpers
|
62
|
+
def _add( addr, name )
|
63
|
+
key = normalize( name )
|
64
|
+
addr2 = @reverse_table[ key ]
|
65
|
+
|
66
|
+
## check for duplicates
|
67
|
+
raise ArgumentError, "duplicate (normalized) key >#{key} for addr >#{addr}<" if addr == addr2
|
68
|
+
raise ArgumentError, "duplicate (normalized) key >#{key}< for addr >#{addr}; addr already in use >#{addr2}<" if addr2
|
69
|
+
@reverse_table[ key ] = addr
|
70
|
+
self
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end # module Ethname
|
75
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Ethname
|
4
|
+
MAJOR = 0
|
5
|
+
MINOR = 0
|
6
|
+
PATCH = 1
|
7
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
8
|
+
|
9
|
+
def self.version
|
10
|
+
VERSION
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"ethname/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.root
|
18
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
|
19
|
+
end
|
20
|
+
|
21
|
+
end # module Ethname
|
22
|
+
|
data/lib/ethname.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'cocos'
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
## our own code
|
6
|
+
require_relative 'ethname/version'
|
7
|
+
require_relative 'ethname/dictionary'
|
8
|
+
|
9
|
+
|
10
|
+
module Ethname
|
11
|
+
|
12
|
+
def self.dict
|
13
|
+
@dict ||= Dictionary.read( "#{root}/config/contracts.2017.csv",
|
14
|
+
"#{root}/config/contracts.2021.csv",
|
15
|
+
"#{root}/config/contracts.2022.csv",
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.lookup( q )
|
20
|
+
dict.lookup( q )
|
21
|
+
end
|
22
|
+
class << self
|
23
|
+
alias_method :[], :lookup
|
24
|
+
end
|
25
|
+
|
26
|
+
end # module Ethname
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
Ethname.banner ## say hello
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ethname
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocos
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '7'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '4.0'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '7'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: hoe
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.23'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.23'
|
61
|
+
description: ethname - light-weight crowd-sourced "off-chain" ethereum name to (contract)
|
62
|
+
address service / helper (incl. punks v1,v2,v3,v4; phunks v1,v2, synth punks, punk
|
63
|
+
blocks, etc.) - yes, you can! - add more names / contracts via git ;-)
|
64
|
+
email: wwwmake@googlegroups.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files:
|
68
|
+
- CHANGELOG.md
|
69
|
+
- Manifest.txt
|
70
|
+
- README.md
|
71
|
+
files:
|
72
|
+
- CHANGELOG.md
|
73
|
+
- Manifest.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- config/contracts.2017.csv
|
77
|
+
- config/contracts.2021.csv
|
78
|
+
- config/contracts.2022.csv
|
79
|
+
- lib/ethname.rb
|
80
|
+
- lib/ethname/dictionary.rb
|
81
|
+
- lib/ethname/version.rb
|
82
|
+
homepage: https://github.com/rubycocos/blockchain
|
83
|
+
licenses:
|
84
|
+
- Public Domain
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options:
|
88
|
+
- "--main"
|
89
|
+
- README.md
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.3'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubygems_version: 3.3.7
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: ethname - light-weight crowd-sourced "off-chain" ethereum name to (contract)
|
107
|
+
address service / helper (incl. punks v1,v2,v3,v4; phunks v1,v2, synth punks, punk
|
108
|
+
blocks, etc.) - yes, you can! - add more names / contracts via git ;-)
|
109
|
+
test_files: []
|