ordinals 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +1 -0
- data/README.md +89 -6
- data/Rakefile +3 -3
- data/lib/ordinals/api.rb +2 -1
- data/lib/ordinals/stats.rb +145 -0
- data/lib/ordinals.rb +12 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e10555694ad5291381edc71af98ba868a6f1f51a42236445873a27e4afbcd177
|
4
|
+
data.tar.gz: a751e7a56a4437d162f055fcf838acbf926a8ab0d89ac7559e99ec2a6f312882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f40f08b9217c1b85a45b3310f21b5acdd14a01d051b989d8abc78cdd88198ec76184b35488fc1f4f5f849224c1793b8e6b23b3ac38b4f36e723b5518b6db8fd6
|
7
|
+
data.tar.gz: bf8d701dd8d75045dc049a7aad636328f616c3a07a5d2a14781b4ac1953dd8a29dfdbea830693ba3e75390fc598e5aa2e06f58d8e6d209e65a19058c5e18b901
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litcoin, Dogecoin & co.
|
4
4
|
|
5
5
|
|
6
|
-
* home :: [github.com/
|
7
|
-
* bugs :: [github.com/
|
6
|
+
* home :: [github.com/ordbase/ordbase](https://github.com/ordbase/ordbase)
|
7
|
+
* bugs :: [github.com/ordbase/ordbase/issues](https://github.com/ordbase/ordbase/issues)
|
8
8
|
* gem :: [rubygems.org/gems/ordinals](https://rubygems.org/gems/ordinals)
|
9
9
|
* rdoc :: [rubydoc.info/gems/ordinals](http://rubydoc.info/gems/ordinals)
|
10
10
|
|
@@ -12,16 +12,99 @@ ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litcoin
|
|
12
12
|
## Usage
|
13
13
|
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
For now ordinal inscription api queries are supported on
|
16
|
+
- Bitcoin (via <https://ordinals.com>)
|
17
|
+
- Litecoin (via <https://ordinalslite.com>) and
|
18
|
+
- Dogecoin (via <https://doginals.com>)
|
19
|
+
|
20
|
+
|
21
|
+
Let's start querying for bitcoin (btc) ordinal inscriptions:
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
require 'ordinals'
|
25
|
+
|
26
|
+
|
27
|
+
# get the inscription binary blob / data by id
|
28
|
+
# e.g. GET https://ordinals.com/content/c41021cb11dce003e6a20a3420cf5954a1d104a1fe314393b915a62f020dcd0ai0...
|
29
|
+
|
30
|
+
id = 'c41021cb11dce003e6a20a3420cf5954a1d104a1fe314393b915a62f020dcd0ai0'
|
31
|
+
content = Ordinals.content( id )
|
32
|
+
pp content
|
33
|
+
#=> #<Ordinals::Api::Content:0x000001a1352df938
|
34
|
+
# @data="RIFF\xF8\v\x00\x00WEBPVP8 \xEC\v\x00\x00...",
|
35
|
+
# @length=3072,
|
36
|
+
# @type="image/png">
|
37
|
+
|
38
|
+
# get the inscription meta data by id
|
39
|
+
# e.g. https://ordinals.com/inscription/c41021cb11dce003e6a20a3420cf5954a1d104a1fe314393b915a62f020dcd0ai0...
|
40
|
+
data = Ordinals.inscription( id )
|
41
|
+
pp data
|
42
|
+
#=> {"title"=>"Inscription 133993",
|
43
|
+
# "id"=>"c41021cb11dce003e6a20a3420cf5954a1d104a1fe314393b915a62f020dcd0ai0",
|
44
|
+
# "address"=>"bc1pyncs638hxfhaqjvnedw2lyc2jta6zuvr9erj6m9cwlghp6qqwvhqeq574l",
|
45
|
+
# "output value"=>"9667",
|
46
|
+
# "sat"=>"1391087135005306",
|
47
|
+
# "preview"=>"link",
|
48
|
+
# "content"=>"link",
|
49
|
+
# "content length"=>"3072 bytes",
|
50
|
+
# "content type"=>"image/png",
|
51
|
+
# "timestamp"=>"2023-02-18 03:02:18 UTC",
|
52
|
+
# "genesis height"=>"777099",
|
53
|
+
# "genesis fee"=>"1814",
|
54
|
+
# "genesis transaction"=>"c41021cb11dce003e6a20a3420cf5954a1d104a1fe314393b915a62f020dcd0a",
|
55
|
+
# "location"=>"6a57dedb854c9bcac3fd2daab1172dd9a45f24c366dd8db33fe80557f11c6b39:22:0",
|
56
|
+
# "output"=>"6a57dedb854c9bcac3fd2daab1172dd9a45f24c366dd8db33fe80557f11c6b39:22",
|
57
|
+
# "offset"=>"0"}
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
Let's try querying for litecoin (ltc) ordinal inscriptions:
|
62
|
+
|
63
|
+
``` ruby
|
64
|
+
Ordinals.chain = :ltc
|
65
|
+
|
66
|
+
|
67
|
+
# get the inscription binary blob / data by id
|
68
|
+
# e.g. GET https://ordinalslite.com/inscription/f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0...
|
69
|
+
|
70
|
+
id = 'f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0'
|
71
|
+
content = Ordinals.content( id )
|
72
|
+
pp content
|
73
|
+
#=> #<Ordinals::Api::Content:0x000001a1357fd6e0
|
74
|
+
# @data="\x89PNG\r\n\x1A\n\x00\x00\x00...",
|
75
|
+
# @length=816,
|
76
|
+
# @type="image/png">
|
77
|
+
|
78
|
+
|
79
|
+
# get the inscription meta data by id
|
80
|
+
# e.g GET https://ordinalslite.com/inscription/f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0...
|
81
|
+
data = Ordinals.inscription( id )
|
82
|
+
pp data
|
83
|
+
#=> {"title"=>"Inscription 642",
|
84
|
+
# "id"=>"f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4i0",
|
85
|
+
# "address"=>"LSDz4fM4mLFyAZVoDuKyMHYq3af6cSZGSY",
|
86
|
+
# "output value"=>"9878",
|
87
|
+
# "preview"=>"link",
|
88
|
+
# "content"=>"link",
|
89
|
+
# "content length"=>"816 bytes",
|
90
|
+
# "content type"=>"image/png",
|
91
|
+
# "timestamp"=>"2023-02-21 05:29:33 UTC",
|
92
|
+
# "genesis height"=>"2426201",
|
93
|
+
# "genesis fee"=>"361",
|
94
|
+
# "genesis transaction"=>"f2b6adf7b2d0f128fb14817ff37f5f36e9176b17571e20c49871875553f937b4",
|
95
|
+
# "location"=>"6802c71b49f18aab91d0b363762b24afb1bf00c4820a5f782de6dd1b1cfbd68a:0:0",
|
96
|
+
# "output"=>"6802c71b49f18aab91d0b363762b24afb1bf00c4820a5f782de6dd1b1cfbd68a:0",
|
97
|
+
# "offset"=>"0"}
|
98
|
+
```
|
99
|
+
|
100
|
+
That's it for now.
|
18
101
|
|
19
102
|
|
20
103
|
|
21
104
|
## Bonus: Ordinal Pixel Art Collections
|
22
105
|
|
23
106
|
|
24
|
-
See the [**Ordinals (Pixel Art) Sandbox (& Cache)**](https://github.com/
|
107
|
+
See the [**Ordinals (Pixel Art) Sandbox (& Cache)**](https://github.com/ordbase/ordinals.sandbox)
|
25
108
|
for collections incl. Ordinal Punks & Phunks (24×24), Bitcoin Punks (24×24), Ordinal Mini Doges (24×24), Ordinal Doggies (32×32),
|
26
109
|
Extra Ordinal Women (32×32), Ordinal Penguins (35×35),
|
27
110
|
Ordinal Birds (42×42), Bitcoin Bears (48×48) and much more.
|
data/Rakefile
CHANGED
@@ -10,15 +10,15 @@ end
|
|
10
10
|
|
11
11
|
Hoe.spec 'ordinals' do
|
12
12
|
|
13
|
-
self.version = '1.0.
|
13
|
+
self.version = '1.0.3'
|
14
14
|
|
15
15
|
self.summary = 'ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litecoin, Dogecoin & co.'
|
16
16
|
self.description = summary
|
17
17
|
|
18
|
-
self.urls = { home: 'https://github.com/
|
18
|
+
self.urls = { home: 'https://github.com/ordbase/ordbase' }
|
19
19
|
|
20
20
|
self.author = 'Gerald Bauer'
|
21
|
-
self.email = '
|
21
|
+
self.email = 'gerald.bauer@gmail.com'
|
22
22
|
|
23
23
|
# switch extension to .markdown for gihub formatting
|
24
24
|
self.readme_file = 'README.md'
|
data/lib/ordinals/api.rb
CHANGED
@@ -5,7 +5,8 @@ module Ordinals
|
|
5
5
|
|
6
6
|
class Api ## change/rename Api to Client - why? why not?
|
7
7
|
def self.litecoin
|
8
|
-
@litecoin ||= new( 'https://litecoin.earlyordies.com' )
|
8
|
+
## @litecoin ||= new( 'https://litecoin.earlyordies.com' )
|
9
|
+
@litecoin ||= new( 'https://ordinalslite.com' )
|
9
10
|
@litecoin
|
10
11
|
end
|
11
12
|
|
@@ -0,0 +1,145 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class InscriptionStats
|
4
|
+
|
5
|
+
TITLE_RX = /^(Inscription|Shibescription)[ ]+(?<ord>[0-9]+)$/
|
6
|
+
BYTES_RX = /^(?<bytes>[0-9]+)[ ]+bytes$/
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@stats = {
|
10
|
+
count: 0,
|
11
|
+
ord: { '<100' => 0,
|
12
|
+
'<1000' => 0,
|
13
|
+
'<10000' => 0,
|
14
|
+
'<100000' => 0,
|
15
|
+
'<1000000' => 0,
|
16
|
+
'min' => nil,
|
17
|
+
'max' => nil, },
|
18
|
+
type: Hash.new(0),
|
19
|
+
bytes: { '<100' => 0,
|
20
|
+
'<1000' => 0,
|
21
|
+
'<10000' => 0,
|
22
|
+
'<100000' => 0,
|
23
|
+
'<1000000' => 0,
|
24
|
+
'min' => nil,
|
25
|
+
'max' => nil, },
|
26
|
+
}
|
27
|
+
|
28
|
+
@days = Hash.new(0)
|
29
|
+
end
|
30
|
+
|
31
|
+
def size() @stats[:count]; end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def update( data )
|
36
|
+
data = JSON.parse( data) if data.is_a?( String )
|
37
|
+
|
38
|
+
@stats[ :count ] += 1
|
39
|
+
|
40
|
+
|
41
|
+
ord = nil
|
42
|
+
if m=TITLE_RX.match( data['title'] )
|
43
|
+
ord = m[:ord].to_i(10)
|
44
|
+
else
|
45
|
+
puts "!! ERROR - cannot find ord in inscription title; sorry"
|
46
|
+
pp data
|
47
|
+
exit 1
|
48
|
+
end
|
49
|
+
|
50
|
+
if ord < 100 then @stats[:ord]['<100'] += 1
|
51
|
+
elsif ord < 1000 then @stats[:ord]['<1000'] += 1
|
52
|
+
elsif ord < 10000 then @stats[:ord]['<10000'] += 1
|
53
|
+
elsif ord < 100000 then @stats[:ord]['<100000'] += 1
|
54
|
+
elsif ord < 1000000 then @stats[:ord]['<1000000'] += 1
|
55
|
+
else
|
56
|
+
puts "!! ERROR ord out-of-bounds"
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
|
60
|
+
## update min/max
|
61
|
+
@stats[:ord]['min'] = ord if ord < (@stats[:ord]['min'] || 9999999)
|
62
|
+
@stats[:ord]['max'] = ord if ord > (@stats[:ord]['max'] || -1)
|
63
|
+
|
64
|
+
|
65
|
+
bytes = nil
|
66
|
+
if m=BYTES_RX.match( data['content length'] )
|
67
|
+
bytes = m[:bytes].to_i(10)
|
68
|
+
else
|
69
|
+
puts "!! ERROR - cannot find bytes in inscription content length; sorry"
|
70
|
+
pp data
|
71
|
+
exit 1
|
72
|
+
end
|
73
|
+
|
74
|
+
if bytes < 100 then @stats[:bytes]['<100'] += 1
|
75
|
+
elsif bytes < 1000 then @stats[:bytes]['<1000'] += 1
|
76
|
+
elsif bytes < 10000 then @stats[:bytes]['<10000'] += 1
|
77
|
+
elsif bytes < 100000 then @stats[:bytes]['<100000'] += 1
|
78
|
+
elsif bytes < 1000000 then @stats[:bytes]['<1000000'] += 1
|
79
|
+
else
|
80
|
+
puts "!! ERROR bytes (content-length) out-of-bounds"
|
81
|
+
exit 1
|
82
|
+
end
|
83
|
+
|
84
|
+
## update min/max
|
85
|
+
@stats[:bytes]['min'] = bytes if bytes < (@stats[:bytes]['min'] || 9999999)
|
86
|
+
@stats[:bytes]['max'] = bytes if bytes > (@stats[:bytes]['max'] || -1)
|
87
|
+
|
88
|
+
|
89
|
+
type = data['content type']
|
90
|
+
|
91
|
+
@stats[:type][ type ] += 1
|
92
|
+
|
93
|
+
## "timestamp"=>"2023-02-05 01:45:22 UTC",
|
94
|
+
ts = Time.strptime( data['timestamp'], '%Y-%m-%d %H:%M:%S' )
|
95
|
+
|
96
|
+
@days[ ts.strftime('%Y-%m-%d') ] +=1
|
97
|
+
end # method update
|
98
|
+
|
99
|
+
|
100
|
+
def data ## rename to model or such - why? why not?
|
101
|
+
## sort days
|
102
|
+
days = @days.sort {|l,r| l[0] <=> r[0] }
|
103
|
+
## add to stats
|
104
|
+
@stats[:days] = {}
|
105
|
+
days.each {|k,v| @stats[:days][k] = v }
|
106
|
+
@stats
|
107
|
+
end
|
108
|
+
|
109
|
+
=begin
|
110
|
+
{:count=>101,
|
111
|
+
:ord=>{"<1000"=>0, "<10000"=>0, "<100000"=>101, "<1000000"=>0, "min"=>14343, "max"=>42901},
|
112
|
+
:type=>{"image/png"=>101},
|
113
|
+
:bytes=>{"<100"=>0, "<1000"=>101, "<10000"=>0, "<100000"=>0, "<1000000"=>0, "min"=>274, "max"=>512},
|
114
|
+
:days=>{"2023-02-22"=>10, "2023-02-25"=>17, "2023-02-26"=>74}}
|
115
|
+
=end
|
116
|
+
|
117
|
+
def format ## rename to pretty_print or such - why? why not?
|
118
|
+
stat = data
|
119
|
+
|
120
|
+
buf = String.new('')
|
121
|
+
buf << "#{stat[:count]} inscription(s)\n"
|
122
|
+
|
123
|
+
buf << "- from ##{stat[:ord]['min']} to ##{stat[:ord]['max']} (min. to max.)\n"
|
124
|
+
buf << " - <100 => #{stat[:ord]['<100']}\n" if stat[:ord]["<100"] > 0
|
125
|
+
buf << " - <1000 => #{stat[:ord]['<1000']}\n" if stat[:ord]["<1000"] > 0
|
126
|
+
buf << " - <10000 => #{stat[:ord]['<10000']}\n" if stat[:ord]["<10000"] > 0
|
127
|
+
buf << " - <100000 => #{stat[:ord]['<100000']}\n" if stat[:ord]["<100000"] > 0
|
128
|
+
buf << " - <1000000 => #{stat[:ord]['<1000000']}\n" if stat[:ord]["<1000000"] > 0
|
129
|
+
|
130
|
+
buf << "- format(s)\n"
|
131
|
+
stat[:type].each do |k,v|
|
132
|
+
buf << " - #{k} => #{v}\n"
|
133
|
+
end
|
134
|
+
|
135
|
+
buf << "- day(s)\n"
|
136
|
+
stat[:days].each do |k,v|
|
137
|
+
buf << " - #{k} => #{v}\n"
|
138
|
+
end
|
139
|
+
|
140
|
+
buf
|
141
|
+
end
|
142
|
+
|
143
|
+
end ## class InscriptionStats
|
144
|
+
|
145
|
+
|
data/lib/ordinals.rb
CHANGED
@@ -54,8 +54,10 @@ module Ordinals
|
|
54
54
|
def self.config() @config ||= Configuration.new; end
|
55
55
|
|
56
56
|
## add some convenience shortcut helpers (no config. required) - why? why not?
|
57
|
-
def self.client()
|
58
|
-
def self.chain()
|
57
|
+
def self.client() config.client; end
|
58
|
+
def self.chain() config.chain; end
|
59
|
+
def self.chain=(value) config.chain = value; end
|
60
|
+
|
59
61
|
|
60
62
|
def self.btc?() config.chain == 'btc'; end
|
61
63
|
def self.ltc?() config.chain == 'ltc'; end
|
@@ -70,6 +72,12 @@ module Ordinals
|
|
70
72
|
alias_method :dogecoin?, :doge?
|
71
73
|
alias_method :dogecon?, :doge?
|
72
74
|
end
|
75
|
+
|
76
|
+
|
77
|
+
###################
|
78
|
+
### more convenience shortcuts
|
79
|
+
def self.inscription( id ) client.inscription( id ); end
|
80
|
+
def self.content( id ) client.content( id ); end
|
73
81
|
end # module Ordinals
|
74
82
|
|
75
83
|
|
@@ -77,5 +85,7 @@ end # module Ordinals
|
|
77
85
|
|
78
86
|
## our own code
|
79
87
|
require_relative 'ordinals/api'
|
88
|
+
require_relative 'ordinals/stats'
|
89
|
+
|
80
90
|
|
81
91
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ordinals
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocos
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
version: '3.23'
|
75
75
|
description: ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin,
|
76
76
|
Litecoin, Dogecoin & co.
|
77
|
-
email:
|
77
|
+
email: gerald.bauer@gmail.com
|
78
78
|
executables: []
|
79
79
|
extensions: []
|
80
80
|
extra_rdoc_files:
|
@@ -88,7 +88,8 @@ files:
|
|
88
88
|
- Rakefile
|
89
89
|
- lib/ordinals.rb
|
90
90
|
- lib/ordinals/api.rb
|
91
|
-
|
91
|
+
- lib/ordinals/stats.rb
|
92
|
+
homepage: https://github.com/ordbase/ordbase
|
92
93
|
licenses:
|
93
94
|
- Public Domain
|
94
95
|
metadata: {}
|