ordinals 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/README.md +70 -0
- data/lib/ordinals/api.rb +25 -10
- data/lib/ordinals/cache.rb +6 -5
- data/lib/ordinals/sandbox.rb +1 -6
- data/lib/ordinals/version.rb +1 -1
- 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: b32e559e689e18de54615ab2528117193b41924127a6ea59ac1c62c4c9adf1a2
|
4
|
+
data.tar.gz: 8f2b06308775f509fe242e8a8c28ddde8864219a4315d051598f45dc7badc9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81da575691583d7f05ff27dda111b80801cb15833a1a5a73f3366315e4e41bbe37e9d7e40bdc89027bf3c39e7b3de78918f356341d490b38ad071b09294a1ec7
|
7
|
+
data.tar.gz: 1f9b179ce9f9e4bd0f11802a94da1388ad5a62ef7357bcfbcecc0bd6c986be10c1c585c0937b6dd1d7db96f342d44d20f727029ddac1e283bb75eea935294d2d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -15,6 +15,7 @@ ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litcoin
|
|
15
15
|
For now ordinal inscription api queries are supported on
|
16
16
|
- Bitcoin (via <https://ordinals.com>) and
|
17
17
|
- Litecoin (via <https://ordinalslite.com>)
|
18
|
+
- Dogecoin (via <https://wonky-ord.dogeord.io>)
|
18
19
|
|
19
20
|
<!--
|
20
21
|
chekc if doginals still in operation???
|
@@ -90,6 +91,10 @@ pp content
|
|
90
91
|
```
|
91
92
|
|
92
93
|
|
94
|
+
Tip: See [**Sub 1k - Inside The First Thousand (Bitcoin) Ordinal Inscriptions**](https://github.com/ordbase/ordbase/blob/master/programming-ordinals/sub1k.md) in the
|
95
|
+
Free (Online) Programming (Bitcoin) Ordinals - Step-by-Step Book(let) / Guide.
|
96
|
+
|
97
|
+
|
93
98
|
|
94
99
|
Let's try querying for litecoin (ltc) ordinal inscriptions:
|
95
100
|
|
@@ -155,6 +160,71 @@ pp data
|
|
155
160
|
# "offset"=>"0"}
|
156
161
|
```
|
157
162
|
|
163
|
+
|
164
|
+
Tip: See [**Sub 1k - Inside The First Thousand (Litecoin) Ordinal Inscriptions**](https://github.com/ordbase/ordbase/blob/master/programming-ordinals/ltc_sub1k.md) in the
|
165
|
+
Free (Online) Programming (Litecoin) Ordinals - Step-by-Step Book(let) / Guide.
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
Let's try querying for dogecoin (doge) ordinal shibescriptions:
|
171
|
+
|
172
|
+
``` ruby
|
173
|
+
Ordinals.chain = :doge
|
174
|
+
|
175
|
+
id = '8f7219639800fdddd510f35bcda52471828ded43753b1d2a42f2a054d006edd8i0'
|
176
|
+
data = Ordinals.inscription( id )
|
177
|
+
pp data
|
178
|
+
# GET https://wonky-ord.dogeord.io/shibescription/8f7219639800fdddd510f35bcda52471828ded43753b1d2a42f2a054d006edd8i0...
|
179
|
+
#=> {"title"=>"Shibescription 35",
|
180
|
+
# "id"=>"8f7219639800fdddd510f35bcda52471828ded43753b1d2a42f2a054d006edd8i0",
|
181
|
+
# "address"=>"D6tMqX2ZrjNunNfohgQPGLT9XpUCN56Zyj",
|
182
|
+
# "output-value"=>"100000",
|
183
|
+
# "content-length"=>"1077 bytes",
|
184
|
+
# "content-type"=>"image/png",
|
185
|
+
# "timestamp"=>"2023-02-24 09:23:06 UTC",
|
186
|
+
# "genesis-height"=>"4609819",
|
187
|
+
# "genesis-fee"=>"34200000",
|
188
|
+
# "genesis-transaction"=>"8f7219639800fdddd510f35bcda52471828ded43753b1d2a42f2a054d006edd8",
|
189
|
+
# "location"=>"8f7219639800fdddd510f35bcda52471828ded43753b1d2a42f2a054d006edd8:0:0",
|
190
|
+
# "output"=>"8f7219639800fdddd510f35bcda52471828ded43753b1d2a42f2a054d006edd8:0",
|
191
|
+
# "offset"=>"0"}
|
192
|
+
|
193
|
+
content = Ordinals.content( id )
|
194
|
+
pp content
|
195
|
+
# GET https://wonky-ord.dogeord.io/content/8f7219639800fdddd510f35bcda52471828ded43753b1d2a42f2a054d006edd8i0...
|
196
|
+
#=> #<Ordinals::Api::Content:0x000001cced0740e8
|
197
|
+
# @data="\x89PNG\r\n\x1A\n\x00\x00\x00...",
|
198
|
+
# @length=1077,
|
199
|
+
# @type="image/png">
|
200
|
+
|
201
|
+
data = Ordinals.inscription( 0 )
|
202
|
+
pp data
|
203
|
+
# GET https://wonky-ord.dogeord.io/shibescription/15f3b73df7e5c072becb1d84191843ba080734805addfccb650929719080f62ei0...
|
204
|
+
#=> {"title"=>"Shibescription 0",
|
205
|
+
# "id"=>"15f3b73df7e5c072becb1d84191843ba080734805addfccb650929719080f62ei0",
|
206
|
+
# "address"=>"DCagMX5GccdpaBFJwDqmPcCaNqSzXtYoVf",
|
207
|
+
# "output-value"=>"100000",
|
208
|
+
# "content-length"=>"1461 bytes",
|
209
|
+
# "content-type"=>"image/png",
|
210
|
+
# "timestamp"=>"2023-02-24 07:45:34 UTC",
|
211
|
+
# "genesis-height"=>"4609723",
|
212
|
+
# "genesis-fee"=>"34200000",
|
213
|
+
# "genesis-transaction"=>"15f3b73df7e5c072becb1d84191843ba080734805addfccb650929719080f62e",
|
214
|
+
# "location"=>"15f3b73df7e5c072becb1d84191843ba080734805addfccb650929719080f62e:0:0",
|
215
|
+
# "output"=>"15f3b73df7e5c072becb1d84191843ba080734805addfccb650929719080f62e:0",
|
216
|
+
# "offset"=>"0"}
|
217
|
+
|
218
|
+
content = Ordinals.content( 0 )
|
219
|
+
pp content
|
220
|
+
# GET https://wonky-ord.dogeord.io/content/15f3b73df7e5c072becb1d84191843ba080734805addfccb650929719080f62ei0...
|
221
|
+
#=> #<Ordinals::Api::Content:0x000001cceda012a0
|
222
|
+
# @data="\x89PNG\r\n\x1A\n\x00\x00...",
|
223
|
+
# @length=1461,
|
224
|
+
# @type="image/png">
|
225
|
+
```
|
226
|
+
|
227
|
+
|
158
228
|
That's it.
|
159
229
|
|
160
230
|
|
data/lib/ordinals/api.rb
CHANGED
@@ -19,7 +19,9 @@ class Api ## change/rename Api to Client - why? why not?
|
|
19
19
|
def self.dogecoin
|
20
20
|
## note: "doginals" call inscriptions
|
21
21
|
## shibescriptions
|
22
|
-
|
22
|
+
##
|
23
|
+
## note: https://doginals.com no longer in operation / working
|
24
|
+
@dogecoin ||= new( 'https://wonky-ord.dogeord.io', inscription: 'shibescription' )
|
23
25
|
@dogecoin
|
24
26
|
end
|
25
27
|
|
@@ -29,8 +31,16 @@ class Api ## change/rename Api to Client - why? why not?
|
|
29
31
|
def initialize( base, inscription: 'inscription' )
|
30
32
|
@base = base
|
31
33
|
@inscription = inscription
|
34
|
+
|
35
|
+
## e.g. inscriptions or shibescriptions (dogecoin)
|
36
|
+
@inscriptions = "#{@inscription}s"
|
37
|
+
|
32
38
|
@requests = 0 ## count requests (for delay_in_s sleeping/throttling)
|
33
39
|
@pages = {} ## (0-)99, (100-)199, (200-)299 etc.
|
40
|
+
|
41
|
+
@inscribe_id_rx = %r{
|
42
|
+
(#{@inscription})/(?<id>[a-fi0-9]+)
|
43
|
+
}ix
|
34
44
|
end
|
35
45
|
|
36
46
|
|
@@ -72,19 +82,15 @@ end ## (nested) class Content
|
|
72
82
|
end
|
73
83
|
|
74
84
|
|
75
|
-
INSCRIBE_ID_RX = %r{
|
76
|
-
inscription/(?<id>[a-fi0-9]+)
|
77
|
-
}ix
|
78
|
-
|
79
85
|
|
80
86
|
def inscription_ids( offset: ) ## note: page size is for now fixed 100
|
81
87
|
ids = []
|
82
88
|
|
83
|
-
src = "#{@base}
|
89
|
+
src = "#{@base}/#{@inscriptions}/#{offset}"
|
84
90
|
res = get( src )
|
85
91
|
|
86
92
|
page = res.text ### assumes utf-8 for now
|
87
|
-
page.scan(
|
93
|
+
page.scan( @inscribe_id_rx ) do |_|
|
88
94
|
m = Regexp.last_match
|
89
95
|
ids << m[:id]
|
90
96
|
end
|
@@ -93,19 +99,28 @@ end ## (nested) class Content
|
|
93
99
|
ids
|
94
100
|
end
|
95
101
|
|
96
|
-
def
|
102
|
+
def _batch_inscription_ids( batch )
|
97
103
|
ids = []
|
98
104
|
limit = 100
|
99
105
|
|
100
|
-
|
106
|
+
batch.times do |i|
|
101
107
|
offset = 99 + limit*i
|
108
|
+
|
102
109
|
puts "==> #{i} - @ #{offset}..."
|
103
|
-
|
110
|
+
## auto-add to page cache - why? why not?
|
111
|
+
ids += (@pages[ offset ] ||= inscription_ids( offset: offset ))
|
104
112
|
end
|
105
113
|
puts " #{ids.size} inscribe id(s) - total"
|
106
114
|
ids
|
107
115
|
end
|
108
116
|
|
117
|
+
## convenience sub1k & frens clubs / helpers
|
118
|
+
def sub1k_ids() _batch_inscription_ids( 10 ); end
|
119
|
+
def sub2k_ids() _batch_inscription_ids( 20 ); end
|
120
|
+
def sub5k_ids() _batch_inscription_ids( 50 ); end
|
121
|
+
def sub10k_ids() _batch_inscription_ids( 100 ); end
|
122
|
+
def sub20k_ids() _batch_inscription_ids( 200 ); end
|
123
|
+
|
109
124
|
|
110
125
|
def _num_to_id( num )
|
111
126
|
limit = 100
|
data/lib/ordinals/cache.rb
CHANGED
@@ -6,10 +6,14 @@ class Cache
|
|
6
6
|
def initialize( dir )
|
7
7
|
@dir = dir
|
8
8
|
@force = false
|
9
|
-
@delay_in_s = 0.5 ## wait 0.5s before next (possible) request
|
10
|
-
@requests = 0
|
11
9
|
end
|
12
10
|
|
11
|
+
##########
|
12
|
+
## config helpers
|
13
|
+
def force?() @force; end
|
14
|
+
def force=(value) @force=value; end
|
15
|
+
|
16
|
+
|
13
17
|
|
14
18
|
|
15
19
|
def json_to_txt( data )
|
@@ -56,7 +60,6 @@ def add( id )
|
|
56
60
|
print "."
|
57
61
|
else
|
58
62
|
print " meta-#{id} "
|
59
|
-
sleep( @delay_in_s ) if @delay_in_s && @requests > 0
|
60
63
|
|
61
64
|
## fetch and cache in cache
|
62
65
|
meta = Ordinals.inscription( id )
|
@@ -64,7 +67,6 @@ def add( id )
|
|
64
67
|
meta_txt = json_to_txt( meta )
|
65
68
|
|
66
69
|
write_text( meta_path, meta_txt )
|
67
|
-
@requests += 1
|
68
70
|
end
|
69
71
|
|
70
72
|
|
@@ -88,7 +90,6 @@ def add( id )
|
|
88
90
|
print "."
|
89
91
|
else
|
90
92
|
print " blob-#{id} "
|
91
|
-
sleep( @delay_in_s ) if @delay_in_s && @requests > 0
|
92
93
|
|
93
94
|
## note: save text as blob - byte-by-byte as is (might be corrupt text)
|
94
95
|
content = Ordinals.content( id )
|
data/lib/ordinals/sandbox.rb
CHANGED
@@ -5,8 +5,6 @@ class Sandbox
|
|
5
5
|
def initialize( dir='./content' )
|
6
6
|
@dir = dir
|
7
7
|
@force = false
|
8
|
-
@delay_in_s = 0.5 ## wait 0.5s before next (possible) request
|
9
|
-
@requests = 0
|
10
8
|
end
|
11
9
|
|
12
10
|
|
@@ -24,9 +22,7 @@ class Sandbox
|
|
24
22
|
path = "#{@dir}/#{id}"
|
25
23
|
if !@force && File.exist?( path )
|
26
24
|
## puts " in sandbox"
|
27
|
-
else
|
28
|
-
sleep( @delay_in_s ) if @delay_in_s && @requests > 0
|
29
|
-
|
25
|
+
else
|
30
26
|
## note: save text as blob - byte-by-byte as is (might be corrupt text)
|
31
27
|
content = Ordinals.content( id )
|
32
28
|
## pp content
|
@@ -38,7 +34,6 @@ class Sandbox
|
|
38
34
|
## puts "data:"
|
39
35
|
## puts content.data
|
40
36
|
write_blob( path, content.data )
|
41
|
-
@requests += 1
|
42
37
|
end
|
43
38
|
end
|
44
39
|
|
data/lib/ordinals/version.rb
CHANGED
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.
|
4
|
+
version: 1.3.0
|
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-08-
|
11
|
+
date: 2023-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocos
|