cryptopunks 2.0.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -3
- data/Manifest.txt +0 -3
- data/README.md +666 -526
- data/Rakefile +40 -32
- data/bin/cryptopunk +17 -17
- data/bin/punk +17 -17
- data/lib/cryptopunks/attributes.rb +147 -147
- data/lib/cryptopunks/colors.rb +162 -162
- data/lib/cryptopunks/composite.rb +38 -38
- data/lib/cryptopunks/contract/punksdata-assets.rb +338 -338
- data/lib/cryptopunks/contract/punksdata-contract.rb +55 -55
- data/lib/cryptopunks/contract/punksdata-meta.rb +2107 -2107
- data/lib/cryptopunks/dataset.rb +67 -67
- data/lib/cryptopunks/image.rb +35 -33
- data/lib/cryptopunks/structs.rb +161 -161
- data/lib/cryptopunks/tool.rb +382 -275
- data/lib/cryptopunks/version.rb +27 -23
- data/lib/cryptopunks.rb +66 -109
- metadata +16 -19
- data/config/spritesheet.csv +0 -402
- data/config/spritesheet.png +0 -0
- data/lib/cryptopunks/generator.rb +0 -223
@@ -1,55 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class CryptopunksData ## check - change class to a module - why? why not?
|
4
|
-
|
5
|
-
|
6
|
-
def self.meta
|
7
|
-
## get all meta data records for all 10 000 punks
|
8
|
-
@meta ||= decode_meta( META_ENCODED )
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.assets
|
12
|
-
@assets ||= ASSETS_ENCODED.sort { |l,r| l[:id] <=> r[:id] }
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def self.punk_attributes( id )
|
18
|
-
## comma-separated values / attribute list in a string
|
19
|
-
asset_nums = meta[ id ] ## id - integer number e.g. 0,1,2,
|
20
|
-
|
21
|
-
asset_nums.map do |num|
|
22
|
-
## note: ASSETS_ENCODED array is zero-based; subtract -1 to start with zero (not one)
|
23
|
-
assets[ num-1 ][:name]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class << self
|
28
|
-
alias_method :attributes, :punk_attributes
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
###
|
33
|
-
# more helpers
|
34
|
-
def self.decode_meta( hex )
|
35
|
-
recs = []
|
36
|
-
|
37
|
-
## note: allow spaces and newlines in hexstring for formatting
|
38
|
-
hex = hex.gsub( /[ \n]/, '' )
|
39
|
-
|
40
|
-
## convert hex string to byte array, that is, array of integer numbers
|
41
|
-
## e.g. 067d7a7e00000000 (0x06 / 0x7d / 0x7a / 0x7e / 0x00 / 0x00 ..)
|
42
|
-
## => [6, 125, 122, 126, 0, 0, 0, 0]
|
43
|
-
a = [hex].pack("H*").unpack('C*')
|
44
|
-
|
45
|
-
a.each_slice( 8 ).with_index do |attributes,i|
|
46
|
-
## filter out (trailing) zeros (0)
|
47
|
-
attributes = attributes.filter { |num| num != 0 }
|
48
|
-
## puts "#{i} => #{attributes.inspect}"
|
49
|
-
|
50
|
-
recs << attributes
|
51
|
-
end
|
52
|
-
recs
|
53
|
-
end
|
54
|
-
end # class CryptopunksData
|
55
|
-
|
1
|
+
|
2
|
+
|
3
|
+
class CryptopunksData ## check - change class to a module - why? why not?
|
4
|
+
|
5
|
+
|
6
|
+
def self.meta
|
7
|
+
## get all meta data records for all 10 000 punks
|
8
|
+
@meta ||= decode_meta( META_ENCODED )
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.assets
|
12
|
+
@assets ||= ASSETS_ENCODED.sort { |l,r| l[:id] <=> r[:id] }
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
def self.punk_attributes( id )
|
18
|
+
## comma-separated values / attribute list in a string
|
19
|
+
asset_nums = meta[ id ] ## id - integer number e.g. 0,1,2,
|
20
|
+
|
21
|
+
asset_nums.map do |num|
|
22
|
+
## note: ASSETS_ENCODED array is zero-based; subtract -1 to start with zero (not one)
|
23
|
+
assets[ num-1 ][:name]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
alias_method :attributes, :punk_attributes
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
###
|
33
|
+
# more helpers
|
34
|
+
def self.decode_meta( hex )
|
35
|
+
recs = []
|
36
|
+
|
37
|
+
## note: allow spaces and newlines in hexstring for formatting
|
38
|
+
hex = hex.gsub( /[ \n]/, '' )
|
39
|
+
|
40
|
+
## convert hex string to byte array, that is, array of integer numbers
|
41
|
+
## e.g. 067d7a7e00000000 (0x06 / 0x7d / 0x7a / 0x7e / 0x00 / 0x00 ..)
|
42
|
+
## => [6, 125, 122, 126, 0, 0, 0, 0]
|
43
|
+
a = [hex].pack("H*").unpack('C*')
|
44
|
+
|
45
|
+
a.each_slice( 8 ).with_index do |attributes,i|
|
46
|
+
## filter out (trailing) zeros (0)
|
47
|
+
attributes = attributes.filter { |num| num != 0 }
|
48
|
+
## puts "#{i} => #{attributes.inspect}"
|
49
|
+
|
50
|
+
recs << attributes
|
51
|
+
end
|
52
|
+
recs
|
53
|
+
end
|
54
|
+
end # class CryptopunksData
|
55
|
+
|