Class: ArtQ::Tool
- Inherits:
-
Object
- Object
- ArtQ::Tool
- Defined in:
- lib/artq.rb
Class Method Summary collapse
- .do_info(contract_address) ⇒ Object
- .do_layers(contract_address) ⇒ Object
- .do_tokens(contract_address) ⇒ Object
- .main(args = ARGV) ⇒ Object
Class Method Details
.do_info(contract_address) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/artq.rb', line 71 def self.do_info( contract_address ) puts "==> query info for art collection contract @ >#{contract_address}<:" c = Contract.new( contract_address ) name = c.name symbol = c.symbol totalSupply = c.totalSupply recs = [] tokenIds = (0..2) tokenIds.each do |tokenId| tokenURI = c.tokenURI( tokenId ) recs << [tokenId, tokenURI] end puts " name: >#{name}<" puts " symbol: >#{symbol}<" puts " totalSupply: >#{totalSupply}<" puts puts " tokenURIs #{tokenIds}:" recs.each do |tokenId, tokenURI| puts " tokenId #{tokenId}:" = Meta.parse( tokenURI ) if .data.empty? ## assume "off-blockchain" if no "on-blockchain" data found puts " #{tokenURI}" else ## assume "on-blockchain" data pp .data puts puts " image_data:" puts .image_data end end end |
.do_layers(contract_address) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/artq.rb', line 108 def self.do_layers( contract_address ) puts "==> query layers for art collection contract @ >#{contract_address}<:" ArtQ.download_layers( contract_address, outdir: "./tmp/#{contract_address}" ) end |
.do_tokens(contract_address) ⇒ Object
115 116 117 118 119 |
# File 'lib/artq.rb', line 115 def self.do_tokens( contract_address ) puts "==> query inline 'on-blockchain' token metadata & images for art collection contract @ >#{contract_address}<:" ArtQ.download_tokens( contract_address, outdir: "./tmp/#{contract_address}" ) end |
.main(args = ARGV) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/artq.rb', line 17 def self.main( args=ARGV ) puts "==> welcome to artq tool with args:" pp args = { } parser = OptionParser.new do |opts| opts.on("--rpc STRING", "JSON RPC Host (default: nil)") do |str| [ :rpc] = str end opts.on("-h", "--help", "Prints this help") do puts opts exit end end parser.parse!( args ) puts "options:" pp puts "args:" pp args if args.size < 1 puts "!! ERROR - no collection found - use <collection> <command>..." puts "" exit end contract_address = args[0] ## todo/check - use collection_name/slug or such? command = args[1] || 'info' if ['i','inf','info'].include?( command ) do_info( contract_address ) elsif ['l', 'layer', 'layers'].include?( command ) do_layers( contract_address ) elsif ['t', 'token', 'tokens'].include?( command ) do_tokens( contract_address ) else puts "!! ERROR - unknown command >#{command}<, sorry" end puts "bye" end |