ordlite 0.1.1 → 0.1.2
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 +1 -1
- data/README.md +146 -1
- data/lib/ordlite/models/inscribe.rb +50 -0
- data/lib/ordlite/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: 238e3e5f3913821c8f0a70bdedb444deeea65da4ecdb5827f239b3b4a682a151
|
4
|
+
data.tar.gz: d01946f571d34b1b29ca7fe0216898f31fddc75e818d07300129af5d1a808c5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1545c336ad9d22d92235bbe7160b3224a311cf5dd06b8a944d18d5d2e80c62a24f342be5ed3b295dd9b99cddd7654f931893f811a9571ef80688956cdff27178
|
7
|
+
data.tar.gz: 7300eb7a35ddcf56a41e10cdbc8844d81f8340147b18125d62a528d1eb27e4f8854e72ff70ec3858723ce2da99a3105b80f4414ec1706a593e81915b1aec9fb5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -11,13 +11,158 @@ ordlite - ordinals inscription (on bitcoin & co) database let's you query via sq
|
|
11
11
|
|
12
12
|
|
13
13
|
|
14
|
+
## SQL Database Model
|
15
|
+
|
16
|
+
Insribes • Blobs
|
17
|
+
|
18
|
+
|
19
|
+
Table Inscribes
|
20
|
+
|
21
|
+
``` sql
|
22
|
+
CREATE TABLE "inscribes" (
|
23
|
+
"id" varchar NOT NULL PRIMARY KEY,
|
24
|
+
"num" integer NOT NULL,
|
25
|
+
"bytes" integer NOT NULL,
|
26
|
+
"content_type" varchar NOT NULL,
|
27
|
+
"date" datetime(6) NOT NULL,
|
28
|
+
"sat" integer NOT NULL,
|
29
|
+
"block" integer NOT NULL,
|
30
|
+
"fee" integer NOT NULL,
|
31
|
+
"tx" varchar NOT NULL,
|
32
|
+
"offset" integer NOT NULL,
|
33
|
+
"address" varchar NOT NULL,
|
34
|
+
"output" varchar NOT NULL,
|
35
|
+
"value" integer NOT NULL,
|
36
|
+
)
|
37
|
+
```
|
38
|
+
|
39
|
+
Table Blobs
|
40
|
+
|
41
|
+
``` sql
|
42
|
+
CREATE TABLE "blobs" (
|
43
|
+
"id" varchar NOT NULL PRIMARY KEY,
|
44
|
+
"content" blob NOT NULL,
|
45
|
+
)
|
46
|
+
```
|
47
|
+
|
48
|
+
|
14
49
|
## Usage
|
15
50
|
|
16
|
-
To be done
|
17
51
|
|
52
|
+
### Step 0: Setup Databae
|
53
|
+
|
54
|
+
``` ruby
|
55
|
+
require 'ordlite'
|
56
|
+
|
57
|
+
OrdDb.connect( adapter: 'sqlite3',
|
58
|
+
database: './ord.db' )
|
59
|
+
|
60
|
+
OrdDb.create_all # build table schema
|
61
|
+
|
62
|
+
puts
|
63
|
+
puts " #{Inscribe.count} inscribe(s)"
|
64
|
+
puts " #{Blob.count} blob(s)"
|
65
|
+
|
66
|
+
#=> 0 inscribe(s)
|
67
|
+
#=> 0 blob(s)
|
68
|
+
```
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
### Example No 1 - Query Ordgen Deploy / Mint Inscriptions
|
74
|
+
|
75
|
+
``` ruby
|
76
|
+
require 'ordlite'
|
77
|
+
|
78
|
+
|
79
|
+
OrdDb.connect( adapter: 'sqlite3',
|
80
|
+
database: './ord.db' )
|
81
|
+
|
82
|
+
|
83
|
+
####################
|
84
|
+
## query for deploy candidates
|
85
|
+
##
|
86
|
+
## e.g. sql where clause like
|
87
|
+
## content LIKE '%deploy%'
|
88
|
+
## AND ( content LIKE '%orc-721%'
|
89
|
+
## OR content LIKE '%og%')
|
90
|
+
##
|
91
|
+
|
92
|
+
deploys = Inscribe.deploys
|
93
|
+
puts " #{deploys.size} deploy candidate(s)"
|
94
|
+
|
95
|
+
deploys.each_with_index do |rec,i|
|
96
|
+
puts "==> deploy #{i} - num #{rec.num} - #{rec.bytes} bytes - #{rec.date}"
|
97
|
+
puts rec.content
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
punks_deploys = Inscribe.deploys_by( slug: 'diypunks')
|
102
|
+
puts " #{punks_deploys.size} deploy candidate(s)"
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
#######################
|
107
|
+
## query for mint candidates
|
108
|
+
##
|
109
|
+
## e.g. sql where clause like
|
110
|
+
## content LIKE '%mint%'
|
111
|
+
## AND ( content LIKE '%orc-721%'
|
112
|
+
## OR content LIKE '%og%')
|
113
|
+
|
114
|
+
mints = Inscribe.mints
|
115
|
+
puts " #{mints.size} mint candidate(s)"
|
116
|
+
|
117
|
+
## print last hundred mint candidates
|
118
|
+
mints[-100,100].each_with_index do |rec,i|
|
119
|
+
puts "==> mint #{i} - num #{rec.num} - #{rec.bytes} bytes - #{rec.date}"
|
120
|
+
puts rec.content
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
phunks_mints = Inscribe.mints_by( slug: 'diyphunks')
|
125
|
+
puts " #{phunks_mints.size} mint candidate(s)"
|
126
|
+
|
127
|
+
|
128
|
+
puts " #{deploys.size} deploy candidate(s)"
|
129
|
+
puts " #{mints.size} mint candidate(s)"
|
130
|
+
|
131
|
+
#=> 123 deploy candidate(s)
|
132
|
+
#=> 7453 mint candidate(s)
|
133
|
+
```
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
### Bonus: Import (Cached) Inscription Datafiles (& Content)
|
139
|
+
|
140
|
+
Let's import all cached
|
141
|
+
inscriptions metadata datafiles (& content)
|
142
|
+
from [/ordinals.cache](https://github.com/ordbase/ordinals.cache)
|
143
|
+
into an (sql) database e.g. `ord.db`:
|
144
|
+
|
145
|
+
|
146
|
+
``` ruby
|
147
|
+
require 'ordlite'
|
148
|
+
|
149
|
+
OrdDb.connect( adapter: 'sqlite3',
|
150
|
+
database: './ord.db' )
|
151
|
+
|
152
|
+
OrdDb.create_all # build table schema
|
153
|
+
|
154
|
+
cache_dir = './ordinals.cache/btc'
|
155
|
+
cache = OrdDb::Cache.new( cache_dir )
|
156
|
+
cache.import_all
|
18
157
|
|
19
158
|
|
159
|
+
puts
|
160
|
+
puts " #{Inscribe.count} inscribe(s)"
|
161
|
+
puts " #{Blob.count} blob(s)"
|
20
162
|
|
163
|
+
#=> 8505 inscribe(s)
|
164
|
+
#=> 7611 blob(s)
|
165
|
+
```
|
21
166
|
|
22
167
|
|
23
168
|
## License
|
@@ -4,6 +4,56 @@ module OrdDb
|
|
4
4
|
|
5
5
|
class Inscribe < ActiveRecord::Base
|
6
6
|
has_one :blob, foreign_key: 'id'
|
7
|
+
|
8
|
+
def content
|
9
|
+
## convernience helper
|
10
|
+
## forward to blob.content
|
11
|
+
blob.content
|
12
|
+
end
|
13
|
+
|
14
|
+
################################
|
15
|
+
### scope like helpers
|
16
|
+
def self.deploys
|
17
|
+
where_clause =<<SQL
|
18
|
+
content LIKE '%deploy%'
|
19
|
+
AND ( content LIKE '%orc-721%'
|
20
|
+
OR content LIKE '%og%')
|
21
|
+
SQL
|
22
|
+
|
23
|
+
joins(:blob).where( where_clause ).order( 'num' )
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.deploys_by( slug: )
|
27
|
+
where_clause =<<SQL
|
28
|
+
content LIKE '%deploy%'
|
29
|
+
AND ( content LIKE '%orc-721%'
|
30
|
+
OR content LIKE '%og%')
|
31
|
+
AND content LIKE '%#{slug}%'
|
32
|
+
SQL
|
33
|
+
|
34
|
+
joins(:blob).where( where_clause ).order( 'num' )
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.mints
|
38
|
+
where_clause =<<SQL
|
39
|
+
content LIKE '%mint%'
|
40
|
+
AND ( content LIKE '%orc-721%'
|
41
|
+
OR content LIKE '%og%')
|
42
|
+
SQL
|
43
|
+
|
44
|
+
joins(:blob).where( where_clause ).order( 'num' )
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.mints_by( slug: )
|
48
|
+
where_clause =<<SQL
|
49
|
+
content LIKE '%mint%'
|
50
|
+
AND ( content LIKE '%orc-721%'
|
51
|
+
OR content LIKE '%og%')
|
52
|
+
AND content LIKE '%#{slug}%'
|
53
|
+
SQL
|
54
|
+
|
55
|
+
joins(:blob).where( where_clause ).order( 'num' )
|
56
|
+
end
|
7
57
|
end # class Inscribe
|
8
58
|
|
9
59
|
end # module Model
|
data/lib/ordlite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ordlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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-07-
|
11
|
+
date: 2023-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|