scribelite 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8423f47a4a80b7687f04a31e0457500faa3b52e48a40e239377f0877271aface
4
- data.tar.gz: 86413fdd0e42317307cb97f0989fca3f8b82736539d4333687ff6c9f158f5915
3
+ metadata.gz: d2a98f4c256e13196f739fb4f538a954f50f51b85ed4bd3fedb3041e66dd3580
4
+ data.tar.gz: 5e9009cef8b739e5e02d630f0e751528a93665d81ba08cecb6ac0e50f8739875
5
5
  SHA512:
6
- metadata.gz: bfb49887358be1a89b68c855cdce8a0c2dbafa3439f76a0ef0c8dea47ceb00316d73d82577ba01f8112a839d7dc468e312ebcc9c4e0882f7f50fd3c5b560ae9e
7
- data.tar.gz: d77a2a72689f2e49292edbcb4c02f74b96b1135a2ccf32a33c20c6e3bd79c12288143f8237ef4e06305d9bfa95c9fd5f7934ca36d1f521284d5269c2a8460cc4
6
+ metadata.gz: 2b920e7a86fe0c47a4b75870c2ae1d27805210b82511bab685cca55af763a93f4f7c9b3124d449eb350b2f22953a920119749b389f6cb357ce5b5750f5282633
7
+ data.tar.gz: 69177a203454d697914a49bf9cfc1b7bc94e00cb149b4a012d01e808433fe7ab0c6d6b3748de8222860d9860a265d2e7d82dc7dcb7c30f246001646aa0a39ec0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,4 @@
1
+ ### 1.0.0
1
2
  ### 0.2.1
2
3
  ### 0.0.1 / 2023-11-21
3
4
 
data/README.md CHANGED
@@ -4,8 +4,8 @@ scribelite - inscription / inscribe (ethscription calldata) database for ethereu
4
4
 
5
5
 
6
6
 
7
- * home :: [github.com/s6ruby/rubidity](https://github.com/s6ruby/rubidity)
8
- * bugs :: [github.com/s6ruby/rubidity/issues](https://github.com/s6ruby/rubidity/issues)
7
+ * home :: [github.com/0xCompute/ethscribe](https://github.com/0xCompute/ethscribe)
8
+ * bugs :: [github.com/0xCompute/ethscribe/issues](https://github.com/0xCompute/ethscribe/issues)
9
9
  * gem :: [rubygems.org/gems/scribelite](https://rubygems.org/gems/scribelite)
10
10
  * rdoc :: [rubydoc.info/gems/scribelite](http://rubydoc.info/gems/scribelite)
11
11
 
@@ -142,7 +142,9 @@ at the ruby code commons (rubycocos) org.
142
142
 
143
143
  ## Questions? Comments?
144
144
 
145
- Join us in the [Rubidity (community) discord (chat server)](https://discord.gg/3JRnDUap6y). Yes you can.
145
+ Join us in the [0xCompute discord (chat server)](https://discord.gg/3JRnDUap6y)
146
+ (or in the more general Ethscription discord).
147
+ Yes you can.
146
148
  Your questions and commentary welcome.
147
149
 
148
150
  Or post them over at the [Help & Support](https://github.com/geraldb/help) page. Thanks.
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ Hoe.spec 'scribelite' do
8
8
  self.summary = "scribelite gem - inscription / inscribe (ethscription calldata) database for ethereum & co; let's you query via sql and more"
9
9
  self.description = summary
10
10
 
11
- self.urls = { home: 'https://github.com/s6ruby/rubidity' }
11
+ self.urls = { home: 'https://github.com/0xCompute/ethscribe' }
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
14
  self.email = 'gerald.bauer@gmail.com'
@@ -2,90 +2,154 @@
2
2
 
3
3
  module ScribeDb
4
4
 
5
+
6
+
5
7
  ## note: by default - sort asc(ending) - oldest first (0,1,2,3, .etc.)
6
- def self.import_ethscriptions( page: 1, sort_order: 'asc' )
7
- net = Ethscribe::Api.mainnet
8
- recs = net.ethscriptions( page: page, sort_order: sort_order )
8
+ def self.import_ethscriptions( page: 1,
9
+ per_page: 50,
10
+ sort_order: 'asc' )
11
+ net = Ethscribe.config.client
12
+ recs = net.ethscriptions( page: page,
13
+ per_page: per_page,
14
+ sort_order: sort_order )
15
+
16
+ puts " #{recs.size} record(s)"
9
17
 
10
18
  recs.each_with_index do |rec,i|
11
19
  puts "==> page #{page}/#{i+1} - #{rec['transaction_hash']}..."
20
+ _import_ethscription( rec )
21
+ end
12
22
 
13
- txid = rec['transaction_hash']
14
- block = rec['block_number']
15
- idx = rec['transaction_index']
16
-
17
- from = rec['creator']
18
- to = rec['initial_owner']
19
-
20
- ## todo - double check if daylight saving time (dst) breaks timestamp == utc identity/conversion?
21
- ## 2001-02-03T04:05:06+07:00
22
- ## 2016-05-29T22:28:15.000Z
23
- ## check if %z can handle .000Z ??
24
- ## DateTime.strptime( '2016-05-29T22:28:15.000Z', '%Y-%m-%dT%H:%M:%S%z' )
25
- ## pp rec['creation_timestamp']
26
- date = DateTime.strptime( rec['creation_timestamp'], '%Y-%m-%dT%H:%M:%S.000Z' )
27
-
28
-
29
- num = rec['ethscription_number']
30
- content_type = rec['mimetype']
31
- data = rec['content_uri']
32
- sha = rec['sha']
33
-
34
- duplicate = rec['esip6']
35
- flagged = rec['image_removed_by_request_of_rights_holder']
36
-
37
- ### check - if flagged
38
- ## content_type always set to text/plain
39
- ## and data to data:, ???
40
- ## (re)set to nil/null - why? why not?
41
- if flagged
42
- data = nil
43
- content_type = nil
44
- end
45
-
46
- tx_attribs = {
47
- id: txid,
48
- block: block,
49
- idx: idx,
50
- date: date,
51
- from: from,
52
- to: to,
53
- data: data, ## note: for now saved as utf8 string (not hex!!!!)
54
- }
55
-
56
- scribe_attribs = {
57
- id: txid,
58
- num: num,
59
- content_type: content_type,
60
- duplicate: duplicate,
61
- flagged: flagged,
62
- sha: sha,
63
- bytes: data ? data.length : nil ## auto-add/calc bytes (content length)
64
- }
65
-
66
-
67
-
68
-
69
- scribe = Scribe.find_by( id: txid )
70
- if scribe
71
- ## skip for now - found id db
72
- else
73
- puts "scribe_attribs:"
74
- pp scribe_attribs
75
- Scribe.create!( **scribe_attribs )
76
- end
23
+ recs.size ## return number of records fetched for now
24
+ end # method import_ethscriptions
25
+
26
+
27
+ def self.sync_facet_txs
28
+ net = Ethscribe.config.client
29
+
30
+ ## add block argument - why? why not?
31
+ ## get count by block e.g.
32
+ ## our_count = Scribe.joins(:tx).where( 'block < ?', new_block_number).count
33
+
34
+
35
+ count = Scribe.count
77
36
 
78
- tx = Tx.find_by( id: txid )
79
- if tx
80
- ## skip for now - found id db
81
- else
82
- puts "tx_attribs:"
83
- pp tx_attribs
84
- Tx.create!( **tx_attribs )
37
+ block = if count > 0
38
+ last_scribe = Scribe.where( num: Scribe.maximum(:num) ).first
39
+ last_scribe.tx.block + 1
40
+ else
41
+ 0
42
+ end
43
+
44
+ loop do
45
+ res = net.newer_facet_txs( block, max: 2500, count: count )
46
+
47
+ break if res['blocks'].size == 0
48
+
49
+ first_block = res['blocks'][0]['block_number']
50
+ last_block = res['blocks'][-1]['block_number']
51
+ puts "==> #{res['blocks'].size} block(s) - #{first_block} to #{last_block}..."
52
+ puts " total_future_ethscriptions: #{res['total_future_ethscriptions']}"
53
+
54
+ batch_count = 0
55
+ res['blocks'].each do |block_rec|
56
+ block_rec['ethscriptions'].each do |rec|
57
+ _import_ethscription( rec )
58
+ count += 1
59
+ batch_count += 1
85
60
  end
86
61
  end
62
+ puts " #{batch_count} record(s) added"
87
63
 
88
- end # method import_ethscriptions
64
+ block = last_block + 1
65
+
66
+ break if res['total_future_ethscriptions'] == 0
67
+ end
68
+ end # method sync_facet_txs
69
+ class << self
70
+ alias_method :sync_facet_txns, :sync_facet_txs
71
+ end
72
+
73
+
74
+
75
+ def self._import_ethscription( rec )
76
+ txid = rec['transaction_hash']
77
+ block = rec['block_number']
78
+ idx = rec['transaction_index']
79
+
80
+ from = rec['creator']
81
+ to = rec['initial_owner']
82
+
83
+ ## todo - double check if daylight saving time (dst) breaks timestamp == utc identity/conversion?
84
+ ## 2001-02-03T04:05:06+07:00
85
+ ## 2016-05-29T22:28:15.000Z
86
+ ## check if %z can handle .000Z ??
87
+ ## DateTime.strptime( '2016-05-29T22:28:15.000Z', '%Y-%m-%dT%H:%M:%S%z' )
88
+ ## pp rec['creation_timestamp']
89
+ date = DateTime.strptime( rec['creation_timestamp'], '%Y-%m-%dT%H:%M:%S.000Z' )
90
+
91
+
92
+ num = rec['ethscription_number']
93
+ content_type = rec['mimetype']
94
+ data = rec['content_uri']
95
+ sha = rec['sha']
96
+
97
+ duplicate = rec['esip6']
98
+ flagged = rec['image_removed_by_request_of_rights_holder']
99
+
100
+ ### check - if flagged
101
+ ## content_type always set to text/plain
102
+ ## and data to data:, ???
103
+ ## (re)set to nil/null - why? why not?
104
+ if flagged
105
+ data = nil
106
+ content_type = nil
107
+ end
108
+
109
+ tx_attribs = {
110
+ id: txid,
111
+ block: block,
112
+ idx: idx,
113
+ date: date,
114
+ from: from,
115
+ to: to,
116
+ data: data, ## note: for now saved as utf8 string (not hex!!!!)
117
+ }
118
+
119
+ scribe_attribs = {
120
+ id: txid,
121
+ num: num,
122
+ content_type: content_type,
123
+ duplicate: duplicate,
124
+ flagged: flagged,
125
+ sha: sha,
126
+ bytes: data ? data.length : nil ## auto-add/calc bytes (content length)
127
+ }
128
+
129
+ if num.nil?
130
+ puts "!! skipping unconfirmed / unassigned inscribe - no. num"
131
+ return
132
+ end
133
+
134
+
135
+ scribe = Scribe.find_by( id: txid )
136
+ if scribe
137
+ ## skip for now - found id db
138
+ else
139
+ # puts "scribe_attribs:"
140
+ # pp scribe_attribs
141
+ Scribe.create!( **scribe_attribs )
142
+ end
143
+
144
+ tx = Tx.find_by( id: txid )
145
+ if tx
146
+ ## skip for now - found id db
147
+ else
148
+ # puts "tx_attribs:"
149
+ # pp tx_attribs
150
+ Tx.create!( **tx_attribs )
151
+ end
152
+ end
89
153
 
90
154
  end # module ScribeDb
91
155
 
@@ -23,6 +23,12 @@ module ScribeDb
23
23
  def self.svg() where( content_type: 'image/svg+xml' ); end
24
24
  def self.avif() where( content_type: 'image/avif' ); end
25
25
 
26
+ def self.pdf() where( content_type: 'application/pdf' ); end
27
+
28
+ def self.facet() where( content_type: 'application/vnd.facet.tx+json' ); end
29
+
30
+
31
+
26
32
  class << self
27
33
  alias_method :jpeg, :jpg
28
34
  end
@@ -1,8 +1,8 @@
1
1
 
2
2
  module Scribelite
3
- MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
- MINOR = 2
5
- PATCH = 1
3
+ MAJOR = 1 ## todo: namespace inside version or something - why? why not??
4
+ MINOR = 0
5
+ PATCH = 0
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scribelite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.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-11-26 00:00:00.000000000 Z
11
+ date: 2024-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ethscribe
@@ -162,14 +162,14 @@ dependencies:
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: '4.0'
165
+ version: '4.1'
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '4.0'
172
+ version: '4.1'
173
173
  description: scribelite gem - inscription / inscribe (ethscription calldata) database
174
174
  for ethereum & co; let's you query via sql and more
175
175
  email: gerald.bauer@gmail.com
@@ -191,7 +191,7 @@ files:
191
191
  - lib/scribelite/models/tx.rb
192
192
  - lib/scribelite/schema.rb
193
193
  - lib/scribelite/version.rb
194
- homepage: https://github.com/s6ruby/rubidity
194
+ homepage: https://github.com/0xCompute/ethscribe
195
195
  licenses:
196
196
  - Public Domain
197
197
  metadata: {}