artq 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -2
- data/lib/artq/layers.rb +8 -4
- data/lib/artq/version.rb +1 -1
- data/lib/artq.rb +40 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 173bf8cbe3bc0e9db811e19b585bd04bc23956b28b1b4cb055c1697288472d7e
|
4
|
+
data.tar.gz: 90c2751c1028ca2986e12825f83d8afbb9055ce864228f5a611a9110481f1439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 339f0a49d30a544ce53892ec7f3c1a04a3ddb47d279ddc938d995ae8efc7c25356db9920a44f06d61a5d3482efe9975a965ba791ca6c6603cc427a6353914ab1
|
7
|
+
data.tar.gz: db571cdfcd4e29e3486199ac775a5494e1f4a42256d7d7449c8adbc3fdf7d4259356863dd3f440b60b94bcc30cf104c365c727965226eefe6a9e1ee849aa23da
|
data/README.md
CHANGED
@@ -184,7 +184,7 @@ and inline svg images in the base64 format get "cut" from the metadata and "past
|
|
184
184
|
```
|
185
185
|
|
186
186
|
|
187
|
-
####
|
187
|
+
#### Case No. 3 - "On-Blockchain" Layers (Incl. Metadata & Images)
|
188
188
|
|
189
189
|
|
190
190
|
Note: Some "on-blockchain" pixel art collections
|
@@ -339,7 +339,43 @@ such as
|
|
339
339
|
and many more.
|
340
340
|
|
341
341
|
|
342
|
-
Tip: For more art collections with "on-blockchain" layers see the [**Art Factory Sandbox »**](https://github.com/pixelartexchange/artfactory.sandbox)
|
342
|
+
Tip: For more art collections with "on-blockchain" layers see the [**Art Factory Sandbox »**](https://github.com/pixelartexchange/artfactory.sandbox)
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
### Using the ArtQ Machinery in Your Own Scripts
|
349
|
+
|
350
|
+
|
351
|
+
Yes, you can. Let's try the (crypto) marcs:
|
352
|
+
|
353
|
+
|
354
|
+
``` ruby
|
355
|
+
require 'artq'
|
356
|
+
|
357
|
+
marcs_eth = "0xe9b91d537c3aa5a3fa87275fbd2e4feaaed69bd0"
|
358
|
+
|
359
|
+
marcs = ArtQ::Contract.new( marcs_eth )
|
360
|
+
|
361
|
+
n = 0
|
362
|
+
m = 0
|
363
|
+
res = marcs.traitData( n, m ) ## note: return binary blob (for n,m-index)
|
364
|
+
pp res
|
365
|
+
#=> ["\x89PNG..."]
|
366
|
+
|
367
|
+
res = marcs.traitDetails( n, m ) ## note: returns tuple (name, mimetype, hide?)
|
368
|
+
pp res
|
369
|
+
#=> ["Zombie", "image/png", false]
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
## or with convenience download_layers helper
|
374
|
+
ArtQ.download_layers( marcs_eth, outdir: './marcs' )
|
375
|
+
```
|
376
|
+
|
377
|
+
|
378
|
+
|
343
379
|
|
344
380
|
|
345
381
|
|
data/lib/artq/layers.rb
CHANGED
@@ -58,7 +58,7 @@ module ArtQ
|
|
58
58
|
buf << "\n"
|
59
59
|
end
|
60
60
|
|
61
|
-
write_text( "#{outdir}/layers.csv", buf )
|
61
|
+
write_text( "#{outdir}/cache/layers.csv", buf )
|
62
62
|
|
63
63
|
#####
|
64
64
|
# try to download all images
|
@@ -71,13 +71,17 @@ module ArtQ
|
|
71
71
|
basename = "#{n}_#{m}"
|
72
72
|
if data.start_with?( PNGSIG )
|
73
73
|
puts "BINGO!! it's a png blob - #{data.size} byte(s)"
|
74
|
-
write_blob( "#{outdir}/#{basename}.png", data )
|
74
|
+
write_blob( "#{outdir}/cache/#{basename}.png", data )
|
75
75
|
elsif data.start_with?( GIF87SIG ) || data.start_with?( GIF89SIG )
|
76
76
|
puts "BINGO!! it's a gif blob - #{data.size} byte(s)"
|
77
|
-
write_blob( "#{outdir}/#{basename}.gif", data )
|
77
|
+
write_blob( "#{outdir}/cache/#{basename}.gif", data )
|
78
78
|
elsif data.start_with?( JPGSIG )
|
79
79
|
puts "BINGO!! it's a jpg blob - #{data.size} byte(s)"
|
80
|
-
write_blob( "#{outdir}/#{basename}.jpg", data )
|
80
|
+
write_blob( "#{outdir}/cache/#{basename}.jpg", data )
|
81
|
+
elsif data.index( /<svg[^>]*?>/i ) ## add more markers to find - why? why not?
|
82
|
+
puts "BINGO!! it's a svg (text) blob - #{data.size} byte(s)"
|
83
|
+
## todo/check - save text as binary blob 1:1 - why? why not?
|
84
|
+
write_blob( "#{outdir}/cache/#{basename}.svg", data )
|
81
85
|
else
|
82
86
|
puts "!! ERROR - unknown image format; sorry"
|
83
87
|
exit 1
|
data/lib/artq/version.rb
CHANGED
data/lib/artq.rb
CHANGED
@@ -14,6 +14,17 @@ module ArtQ
|
|
14
14
|
|
15
15
|
class Tool
|
16
16
|
|
17
|
+
|
18
|
+
def self.is_addr?( str )
|
19
|
+
## e.g.
|
20
|
+
## must for now start with 0x (or 0X)
|
21
|
+
## and than 40 hexdigits (20 bytes)
|
22
|
+
## e.g. 0xe21ebcd28d37a67757b9bc7b290f4c4928a430b1
|
23
|
+
str.match( /\A0x[0-9a-f]{40}\z/i )
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
17
28
|
def self.main( args=ARGV )
|
18
29
|
puts "==> welcome to artq tool with args:"
|
19
30
|
pp args
|
@@ -47,16 +58,38 @@ class Tool
|
|
47
58
|
exit
|
48
59
|
end
|
49
60
|
|
50
|
-
|
61
|
+
|
62
|
+
## todo/check - use collection_name/slug or such?
|
63
|
+
contract_address = nil
|
64
|
+
outdir = nil
|
65
|
+
|
66
|
+
if is_addr?( args[0] ) ## do nothing; it's an address
|
67
|
+
contract_address = args[0]
|
68
|
+
outdir = "./tmp/#{contract_address}"
|
69
|
+
else ## try reading collection.yml config
|
70
|
+
config_path = "./#{args[0]}/collection.yml"
|
71
|
+
if File.exist?( config_path )
|
72
|
+
config = read_yaml( config_path )
|
73
|
+
contract_address = config['token']['contract']
|
74
|
+
outdir = "./#{args[0]}"
|
75
|
+
else
|
76
|
+
puts "!! ERROR - no config found for collection >#{contract_address}<; sorry"
|
77
|
+
exit 1
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
51
82
|
command = args[1] || 'info'
|
52
83
|
|
53
84
|
|
54
85
|
if ['i','inf','info'].include?( command )
|
55
86
|
do_info( contract_address )
|
56
87
|
elsif ['l', 'layer', 'layers'].include?( command )
|
57
|
-
|
88
|
+
## note: outdir - save into cache for now
|
89
|
+
do_layers( contract_address, outdir: outdir )
|
58
90
|
elsif ['t', 'token', 'tokens'].include?( command )
|
59
|
-
|
91
|
+
## note: outdir - saves into token (metadata) & token-i (images)
|
92
|
+
do_tokens( contract_address, outdir: outdir )
|
60
93
|
else
|
61
94
|
puts "!! ERROR - unknown command >#{command}<, sorry"
|
62
95
|
end
|
@@ -105,17 +138,17 @@ class Tool
|
|
105
138
|
|
106
139
|
|
107
140
|
|
108
|
-
def self.do_layers( contract_address )
|
141
|
+
def self.do_layers( contract_address, outdir: )
|
109
142
|
puts "==> query layers for art collection contract @ >#{contract_address}<:"
|
110
143
|
|
111
144
|
ArtQ.download_layers( contract_address,
|
112
|
-
outdir:
|
145
|
+
outdir: outdir )
|
113
146
|
end
|
114
147
|
|
115
|
-
def self.do_tokens( contract_address )
|
148
|
+
def self.do_tokens( contract_address, outdir: )
|
116
149
|
puts "==> query inline 'on-blockchain' token metadata & images for art collection contract @ >#{contract_address}<:"
|
117
150
|
ArtQ.download_tokens( contract_address,
|
118
|
-
outdir:
|
151
|
+
outdir: outdir )
|
119
152
|
end
|
120
153
|
|
121
154
|
end # class Tool
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ethlite
|