ethscribe 0.1.0 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4217cdc814f3b713841774ed4eec4abe0f024d598e365a5b7b34e142f555d77
4
- data.tar.gz: a28f4ca71df40a9da404ccc817e2e4ae13b247da8a44ea4878d5fee9e0f54a6b
3
+ metadata.gz: 54c1bc99feba882f271fdf9e1158cf47c09e4611664d3d2d27fc770e2d3e4882
4
+ data.tar.gz: 5a0297d9ccb9df224707b34101803a262f21bb63bf2e2debb963913296654551
5
5
  SHA512:
6
- metadata.gz: e3d408e310e9df8cd9ef4df9376d854f3d243eabd321920071d27d6a94131e03114865427ee36c5dbf97693a1893ba4329d0cd1e56278611519f2f05f4b57185
7
- data.tar.gz: 9cb5cb71409a5e8280ea5be41c1c2c07b1ea0602766caee4168decb8a530a3f99931d950f4d28074905505fc76225530a13517126bd57da2f9039a23e93ac050
6
+ metadata.gz: 3bd5ff76a13b14e43ad80ba4ba742e19bfebf13491f4ad77ec6feeaac636ec8d0b1c90f749e7371812df1e186813a1885001b682ec4ca9ed40acc13bebc41656
7
+ data.tar.gz: a8477a3ff5e4ced79055b3292f2731eb9088976ddaea275e2fbc8bf23809ea4bbbf8bc52dec9be6014b41cab58038bcb5ac3d9dc301c7be99281625c87e5e21d
data/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
- ### 0.1.0
1
+ ### 1.0.0
2
+ ### 0.2.0
2
3
  ### 0.0.1 / 2023-11-20
3
4
 
4
5
  * Everything is new. First release
data/README.md CHANGED
@@ -1,22 +1,104 @@
1
- # Ethscribe - Inscription (Ethscription Calldata) API Wrapper & Helpers for Ethereum & Co.
1
+ # Ethscribe - Inscription / Inscribe (Ethscription Calldata) API Wrapper & Helpers for Ethereum & Co.
2
2
 
3
- ethscribe - inscription (ethscription calldata) api wrapper & helpers for Ethereum & co.
3
+ ethscribe - inscription / inscribe (ethscription calldata) api wrapper & helpers for Ethereum & co.
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/ethscribe](https://rubygems.org/gems/ethscribe)
10
10
  * rdoc :: [rubydoc.info/gems/ethscribe](http://rubydoc.info/gems/ethscribe)
11
11
 
12
12
 
13
- ## What's Ethscription Calldata / Ethereum Inscription?!
14
13
 
15
- To be done...
14
+ ## What's Ethscription Calldata - Ethereum Inscription / Inscribe?!
16
15
 
16
+ See [Introducing Ethscriptions - A new way of creating and sharing digital artifacts on the Ethereum blockchain using transaction calldata »](https://medium.com/@dumbnamenumbers/introducing-ethscriptions-698b295d6f2a)
17
17
 
18
18
 
19
19
 
20
+ ## Usage
21
+
22
+ This is a little "lite" wrapper around the ethscriptions.com api(s).
23
+
24
+
25
+ > The Ethscriptions.com API (v1)
26
+ > does not require a key, however it is rate limited.
27
+ > If you need more throughput, contact Middlemarch on Twitter.
28
+ >
29
+ > If you build something cool, also contact Middlemarch on Twitter!
30
+ >
31
+ > There is a goerli API and a mainnet API. The base URIs are:
32
+ >
33
+ > - https://goerli-api.ethscriptions.com/api
34
+ > - https://mainnet-api.ethscriptions.com/api
35
+ >
36
+ > Append the below paths, plus a query string if you want, to access the API!
37
+ >
38
+ > -- [Introducing the Ethscriptions.com API (v1)](https://medium.com/@dumbnamenumbers/introducing-the-ethscriptions-com-api-v1-6d2c507d82cd)
39
+
40
+
41
+
42
+ The (ethereum) goerli testnet api is wrapped in `Ethscribe::Api.goerli` and
43
+ the (ethereum) mainnet api is wrapped in `Ethscribe::Api.mainnet`.
44
+
45
+ Let's try the mainnet:
46
+
47
+ ```ruby
48
+ require 'ethscribe'
49
+
50
+ net = Ethscribe::Api.mainnet # or Ethscribe::Api.goerli
51
+
52
+
53
+ # get latest 25 inscriptions (defaults: page_size=25, sort_order=desc)
54
+ pp net.ethscriptions
55
+
56
+ # get inscriptions page 1 (same as above)
57
+ pp net.ethscriptions( page: 1 )
58
+
59
+ # get inscriptions page 2
60
+ pp net.ethscriptions( page: 2 )
61
+
62
+ # get oldest first - sort_order=asc
63
+ pp net.ethscriptions( page: 1, sort_order: 'asc' )
64
+ pp net.ethscriptions( page: 2, sort_order: 'asc' )
65
+
66
+
67
+ # get inscription by id or num
68
+ pp net.ethscription( 0 )
69
+ pp net.ethscription( 1 )
70
+ pp net.ethscription( 1000 )
71
+ pp net.ethscription( 1_000_000 )
72
+
73
+
74
+ # get inscriptions owned by <addresss>
75
+ address = '0x2a878245b52a2d46cb4327541cbc96e403a84791'
76
+ pp net.ethscriptions_owned_by( address )
77
+
78
+
79
+ # get inscription (decoded) content_data and content_type by id or num
80
+ pp net.ethscription_data( 0 )
81
+ pp net.ethscription_data( 1 )
82
+ pp net.ethscription_data( 2 )
83
+
84
+
85
+ # check if content exists (using sha256 hash)
86
+ # inscribe no. 0
87
+ sha = '2817fd9cf901e4435253881550731a5edc5e519c19de46b08e2b19a18e95143e'
88
+ pp net.ethscription_exists( sha )
89
+
90
+ # inscribe no. ??
91
+ sha = '2817fd9cf901e4435253833550731a5edc5e519c19de46b08e2b19a18e95143e'
92
+ pp net.ethscription_exists( sha )
93
+
94
+ # check the indexer (block) status
95
+ pp net.block_status
96
+ ```
97
+
98
+
99
+ That's it for now.
100
+
101
+
20
102
 
21
103
  ## Bonus - More Blockchain (Crypto) Tools, Libraries & Scripts In Ruby
22
104
 
@@ -26,7 +108,9 @@ at the ruby code commons (rubycocos) org.
26
108
 
27
109
  ## Questions? Comments?
28
110
 
29
- Join us in the [Rubidity (community) discord (chat server)](https://discord.gg/3JRnDUap6y). Yes you can.
111
+ Join us in the [0xCompute discord (chat server)](https://discord.gg/3JRnDUap6y)
112
+ (or in the more general Ethscription discord).
113
+ Yes you can.
30
114
  Your questions and commentary welcome.
31
115
 
32
116
  Or post them over at the [Help & Support](https://github.com/geraldb/help) page. Thanks.
data/Rakefile CHANGED
@@ -5,10 +5,10 @@ require './lib/ethscribe/version.rb'
5
5
  Hoe.spec 'ethscribe' do
6
6
  self.version = Ethscribe::VERSION
7
7
 
8
- self.summary = 'ethscribe - inscription (ethscription calldata) api wrapper & helpers for Ethereum & co.'
8
+ self.summary = 'ethscribe - inscription / inscribe (ethscription calldata) api wrapper & helpers for Ethereum & co.'
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'
data/lib/ethscribe/api.rb CHANGED
@@ -25,10 +25,16 @@ class Api ## change/rename Api to Client - why? why not?
25
25
  @requests = 0 ## count requests (for delay_in_s sleeping/throttling)
26
26
  end
27
27
 
28
- #########
29
- # page - integer (starting at 1)
30
- # per_page - integer (default: 25)
31
- # sort_order - string "asc" or "desc" (default: desc - latest first)
28
+
29
+ #
30
+ # Get all ethscriptions
31
+ #
32
+ # /ethscriptions
33
+ #
34
+ # Query parameters:
35
+ # page - integer (starting at 1)
36
+ # per_page - integer (default: 25 - max: 50)
37
+ # sort_order - string "asc" or "desc" (default: desc - latest first)
32
38
 
33
39
 
34
40
  def ethscriptions( page: nil, per_page: nil, sort_order: nil )
@@ -39,7 +45,7 @@ class Api ## change/rename Api to Client - why? why not?
39
45
  params << ['sort_order', sort_order.to_s.downcase ] if sort_order
40
46
 
41
47
  if params.size > 0
42
- src += "?" + params.map { |key,value| "#{key}=#{value}" }.join('&')
48
+ src += "?" + params.map { |key,value| "#{key}=#{URI.encode_uri_component(value)}" }.join('&')
43
49
  end
44
50
 
45
51
  res = get( src )
@@ -47,6 +53,172 @@ class Api ## change/rename Api to Client - why? why not?
47
53
  end
48
54
 
49
55
 
56
+ ####
57
+ # ContractTransaction.transaction_mimetype
58
+ # "application/vnd.facet.tx+json"
59
+ # SystemConfigVersion.system_mimetype
60
+ # "application/vnd.facet.system+json"
61
+ def newer_facet_txs( new_block_number,
62
+ max: 2500,
63
+ max_blocks: 10000,
64
+ count: 0 )
65
+ newer_ethscriptions( new_block_number,
66
+ max_ethscriptions: max,
67
+ max_blocks: max_blocks,
68
+ mimetypes: ['application/vnd.facet.tx+json',
69
+ 'application/vnd.facet.system+json'],
70
+ count: count
71
+ )
72
+ end
73
+ alias_method :newer_facet_txns, :newer_facet_txs
74
+
75
+ ## add "undocumented" endpoint
76
+ ## /ethscriptions/newer_ethscriptions
77
+ ##
78
+ ## see https://github.com/0xFacet/facet-vm/blob/main/app/models/ethscription_sync.rb
79
+
80
+ def newer_ethscriptions( new_block_number,
81
+ max_ethscriptions: 2500,
82
+ max_blocks: 10000,
83
+ mimetypes: [],
84
+ count: 0
85
+ )
86
+ src = "#{@base}/ethscriptions/newer_ethscriptions"
87
+
88
+ params = []
89
+ params << ['block_number', new_block_number.to_s]
90
+
91
+ ## note: array MUST use rails convention with []
92
+ mimetypes.each do |mimetype|
93
+ params << ['mimetypes[]', mimetype]
94
+ end
95
+
96
+ params << ['max_ethscriptions', max_ethscriptions.to_s]
97
+ params << ['max_blocks', max_blocks.to_s ]
98
+ params << ['past_ethscriptions_count', count.to_s]
99
+
100
+ src += "?" + params.map do |key,value|
101
+ "#{URI.encode_uri_component(key)}=#{URI.encode_uri_component(value)}"
102
+ end.join('&')
103
+
104
+ res = get( src )
105
+ res.json ## return parsed json data - why? why not?
106
+ end
107
+
108
+
109
+ #
110
+ # Get ethscriptions owned by address
111
+ #
112
+ # /ethscriptions/owned_by/:address
113
+ #
114
+ # Query parameters: page, per_page( max 1000), sort_order (asc / desc)
115
+
116
+ def ethscriptions_owned_by( address )
117
+ src = "#{@base}/ethscriptions/owned_by/#{address}"
118
+
119
+ res = get( src )
120
+ res.json ## return parsed json data - why? why not?
121
+ end
122
+
123
+
124
+
125
+ #
126
+ # Get specific ethscription
127
+ #
128
+ # /ethscriptions/:ethscription_id
129
+ #
130
+ # Or
131
+ #
132
+ # /ethscriptions/:ethscription_number
133
+ #
134
+ # (ethscription_id is the transaction hash of the transaction that created the ethscription)
135
+
136
+ # note: use singular (overload method by args not possible in ruby)
137
+ def ethscription( id_or_num )
138
+ src = "#{@base}/ethscriptions/#{id_or_num}"
139
+ res = get( src )
140
+ res.json ## return parsed json data - why? why not?
141
+ end
142
+
143
+ #
144
+ # Get data of an ethscription
145
+ #
146
+ # /ethscriptions/:ethscription_id/data
147
+ #
148
+ # Or
149
+ #
150
+ # /ethscriptions/:ethscription_number/data
151
+ #
152
+ # This will return the ethscription's raw decoded data in the correct mimetype
153
+
154
+
155
+ ###
156
+ # use a struct-like content class - why? why not?
157
+ class Content
158
+ attr_reader :data,
159
+ :type,
160
+ :length
161
+ def initialize( data, type, length )
162
+ @data = data
163
+ @type = type
164
+ @length = length
165
+ end
166
+
167
+ alias_method :blob, :data
168
+ end ## (nested) class Content
169
+
170
+
171
+ def ethscription_data( id_or_num )
172
+ src = "#{@base}/ethscriptions/#{id_or_num}/data"
173
+ res = get( src )
174
+
175
+ content_type = res.content_type
176
+ content_length = res.content_length
177
+
178
+ ## note - content_length -- returns an integer (number)
179
+ ## puts "content_length:"
180
+ ## print content_length.inspect
181
+ ## print " - #{content_length.class.name}\n"
182
+
183
+ ## fix-fix-fix
184
+ ## if text/json/svg type etc.
185
+ ## convert to utf8 (from binary blob why? why not?) - why? why not?
186
+ ## or add text accessor to content?
187
+
188
+ content = Content.new(
189
+ res.blob,
190
+ content_type,
191
+ content_length )
192
+ content
193
+ end
194
+
195
+
196
+ ###
197
+ # Check whether content is already ethscribed
198
+ #
199
+ # /ethscriptions/exists/:sha
200
+ #
201
+ # Where sha is the sha256 of the UTF-8 data URI
202
+
203
+ # {"result":false,"ethscription":null}
204
+
205
+ def ethscription_exists( sha )
206
+ src = "#{@base}/ethscriptions/exists/#{sha}"
207
+ res = get( src )
208
+ res.json ## return parsed json data - why? why not?
209
+ end
210
+
211
+ # Determine if the indexer is behind
212
+ #
213
+ # {"current_block_number":18619883,"last_imported_block":18619883,"blocks_behind":0}
214
+
215
+ def block_status
216
+ src = "#{@base}/block_status"
217
+ res = get( src )
218
+ res.json ## return parsed json data - why? why not?
219
+ end
220
+
221
+
50
222
  def get( src )
51
223
  @requests += 1
52
224
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Ethscribe
3
- MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
- MINOR = 1
3
+ MAJOR = 1 ## todo: namespace inside version or something - why? why not??
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
data/lib/ethscribe.rb CHANGED
@@ -69,6 +69,7 @@ module Ethscribe
69
69
  ### more convenience shortcuts
70
70
 
71
71
  def self.inscribes( **kwargs ) client.ethscriptions( **kwargs ); end
72
+ def self.inscribe( id_or_num ) client.ethscription( id_or_num ); end
72
73
  end # module Ethscribe
73
74
 
74
75
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethscribe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
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-21 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: cocos
@@ -50,16 +50,16 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '4.0'
53
+ version: '4.1'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '4.0'
61
- description: ethscribe - inscription (ethscription calldata) api wrapper & helpers
62
- for Ethereum & co.
60
+ version: '4.1'
61
+ description: ethscribe - inscription / inscribe (ethscription calldata) api wrapper
62
+ & helpers for Ethereum & co.
63
63
  email: gerald.bauer@gmail.com
64
64
  executables: []
65
65
  extensions: []
@@ -75,7 +75,7 @@ files:
75
75
  - lib/ethscribe.rb
76
76
  - lib/ethscribe/api.rb
77
77
  - lib/ethscribe/version.rb
78
- homepage: https://github.com/s6ruby/rubidity
78
+ homepage: https://github.com/0xCompute/ethscribe
79
79
  licenses:
80
80
  - Public Domain
81
81
  metadata: {}
@@ -99,6 +99,6 @@ requirements: []
99
99
  rubygems_version: 3.4.10
100
100
  signing_key:
101
101
  specification_version: 4
102
- summary: ethscribe - inscription (ethscription calldata) api wrapper & helpers for
103
- Ethereum & co.
102
+ summary: ethscribe - inscription / inscribe (ethscription calldata) api wrapper &
103
+ helpers for Ethereum & co.
104
104
  test_files: []