ethscribe 0.0.1 → 0.1.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 +4 -4
- data/CHANGELOG.md +1 -0
- data/Manifest.txt +2 -0
- data/Rakefile +4 -3
- data/lib/ethscribe/api.rb +72 -0
- data/lib/ethscribe/version.rb +19 -0
- data/lib/ethscribe.rb +91 -1
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4217cdc814f3b713841774ed4eec4abe0f024d598e365a5b7b34e142f555d77
|
4
|
+
data.tar.gz: a28f4ca71df40a9da404ccc817e2e4ae13b247da8a44ea4878d5fee9e0f54a6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3d408e310e9df8cd9ef4df9376d854f3d243eabd321920071d27d6a94131e03114865427ee36c5dbf97693a1893ba4329d0cd1e56278611519f2f05f4b57185
|
7
|
+
data.tar.gz: 9cb5cb71409a5e8280ea5be41c1c2c07b1ea0602766caee4168decb8a530a3f99931d950f4d28074905505fc76225530a13517126bd57da2f9039a23e93ac050
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'hoe'
|
2
|
-
|
2
|
+
require './lib/ethscribe/version.rb'
|
3
3
|
|
4
4
|
|
5
5
|
Hoe.spec 'ethscribe' do
|
6
|
-
self.version =
|
6
|
+
self.version = Ethscribe::VERSION
|
7
7
|
|
8
|
-
self.summary = 'ethscribe
|
8
|
+
self.summary = 'ethscribe - inscription (ethscription calldata) api wrapper & helpers for Ethereum & co.'
|
9
9
|
self.description = summary
|
10
10
|
|
11
11
|
self.urls = { home: 'https://github.com/s6ruby/rubidity' }
|
@@ -18,6 +18,7 @@ Hoe.spec 'ethscribe' do
|
|
18
18
|
self.history_file = 'CHANGELOG.md'
|
19
19
|
|
20
20
|
self.extra_deps = [
|
21
|
+
['cocos'],
|
21
22
|
]
|
22
23
|
|
23
24
|
self.licenses = ['Public Domain']
|
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Ethscribe
|
4
|
+
|
5
|
+
|
6
|
+
class Api ## change/rename Api to Client - why? why not?
|
7
|
+
def self.goerli
|
8
|
+
@goerli ||= new( 'https://goerli-api.ethscriptions.com/api' )
|
9
|
+
@goerli
|
10
|
+
end
|
11
|
+
## todo: add test alias - why? why not?
|
12
|
+
|
13
|
+
def self.mainnet
|
14
|
+
@mainnet ||= new( 'https://api.ethscriptions.com/api' )
|
15
|
+
@mainnet
|
16
|
+
end
|
17
|
+
## todo: add eth, main or production alias - why? why not?
|
18
|
+
|
19
|
+
|
20
|
+
def config() Ethscribe.config; end ## convenience shortcut helper
|
21
|
+
|
22
|
+
|
23
|
+
def initialize( base )
|
24
|
+
@base = base
|
25
|
+
@requests = 0 ## count requests (for delay_in_s sleeping/throttling)
|
26
|
+
end
|
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)
|
32
|
+
|
33
|
+
|
34
|
+
def ethscriptions( page: nil, per_page: nil, sort_order: nil )
|
35
|
+
src = "#{@base}/ethscriptions"
|
36
|
+
params = []
|
37
|
+
params << ['page', page.to_s] if page
|
38
|
+
params << ['per_page', per_page.to_s] if per_page
|
39
|
+
params << ['sort_order', sort_order.to_s.downcase ] if sort_order
|
40
|
+
|
41
|
+
if params.size > 0
|
42
|
+
src += "?" + params.map { |key,value| "#{key}=#{value}" }.join('&')
|
43
|
+
end
|
44
|
+
|
45
|
+
res = get( src )
|
46
|
+
res.json ## return parsed json data - why? why not?
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def get( src )
|
51
|
+
@requests += 1
|
52
|
+
|
53
|
+
if @requests > 1 && config.delay_in_s
|
54
|
+
puts "request no. #{@requests}@#{@base}; sleeping #{config.delay_in_s} sec(s)..."
|
55
|
+
sleep( config.delay_in_s )
|
56
|
+
end
|
57
|
+
|
58
|
+
res = Webclient.get( src )
|
59
|
+
|
60
|
+
if res.status.ok?
|
61
|
+
res
|
62
|
+
else
|
63
|
+
## todo/fix: raise exception here!!!!
|
64
|
+
puts "!! ERROR - HTTP #{res.status.code} #{res.status.message} - failed web request >#{src}<; sorry"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end # class Api
|
69
|
+
|
70
|
+
|
71
|
+
end ## module Ethscibe
|
72
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
module Ethscribe
|
3
|
+
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
4
|
+
MINOR = 1
|
5
|
+
PATCH = 0
|
6
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
7
|
+
|
8
|
+
def self.version
|
9
|
+
VERSION
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.banner
|
13
|
+
"ethscribe/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in >#{root}<"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.root
|
17
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
|
18
|
+
end
|
19
|
+
end
|
data/lib/ethscribe.rb
CHANGED
@@ -1,3 +1,93 @@
|
|
1
|
+
require 'cocos'
|
1
2
|
|
2
|
-
|
3
|
+
|
4
|
+
|
5
|
+
module Ethscribe
|
6
|
+
class Configuration
|
7
|
+
|
8
|
+
#######################
|
9
|
+
## accessors
|
10
|
+
def chain=(value)
|
11
|
+
if value.is_a?( String ) || value.is_a?( Symbol )
|
12
|
+
case value.downcase.to_s
|
13
|
+
when 'mainnet' # 'main', 'eth', 'prod', 'production'
|
14
|
+
@chain = 'mainnet'
|
15
|
+
@client = Ethscribe::Api.mainnet
|
16
|
+
when 'goerli' # 'testnet', 'test'
|
17
|
+
@chain = 'goerli'
|
18
|
+
@client = Ethscribe::Api.goerli
|
19
|
+
else
|
20
|
+
raise ArgumentError, "unknown chain - expected mainnet | goerli; got #{value}"
|
21
|
+
end
|
22
|
+
else
|
23
|
+
raise ArgumentError, "only string or symbol supported for now; sorry - got: #{value.inspect} : #{value.class.name}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def chain
|
28
|
+
## note - default to mainnet if not set
|
29
|
+
self.chain = 'mainnet' unless defined?( @chain )
|
30
|
+
@chain
|
31
|
+
end
|
32
|
+
|
33
|
+
## note: read-only for now - why? why not?
|
34
|
+
def client
|
35
|
+
## note - default to btc/ if not set
|
36
|
+
self.chain = 'mainnet' unless defined?( @client )
|
37
|
+
@client
|
38
|
+
end
|
39
|
+
|
40
|
+
def delay_in_s
|
41
|
+
## note - default to 1 (sec) if not set
|
42
|
+
self.delay_in_s = 1 unless defined?( @delay_in_s )
|
43
|
+
@delay_in_s
|
44
|
+
end
|
45
|
+
def delay_in_s=(value) @delay_in_s = value; end
|
46
|
+
alias_method :sleep, :delay_in_s ## add sleep alias (or wait) - why? why not?
|
47
|
+
alias_method :sleep=, :delay_in_s=
|
48
|
+
end # class Configuration
|
49
|
+
|
50
|
+
|
51
|
+
## lets you use
|
52
|
+
## Ordinals.configure do |config|
|
53
|
+
## config.chain = :btc
|
54
|
+
## end
|
55
|
+
def self.configure() yield( config ); end
|
56
|
+
def self.config() @config ||= Configuration.new; end
|
57
|
+
|
58
|
+
## add some convenience shortcut helpers (no config. required) - why? why not?
|
59
|
+
def self.client() config.client; end
|
60
|
+
def self.chain() config.chain; end
|
61
|
+
def self.chain=(value) config.chain = value; end
|
62
|
+
|
63
|
+
|
64
|
+
def self.mainnet?() config.chain == 'mainnet'; end
|
65
|
+
def self.goerli?() config.chain == 'goerli'; end
|
66
|
+
|
67
|
+
|
68
|
+
###################
|
69
|
+
### more convenience shortcuts
|
70
|
+
|
71
|
+
def self.inscribes( **kwargs ) client.ethscriptions( **kwargs ); end
|
72
|
+
end # module Ethscribe
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
## our own code
|
78
|
+
require_relative 'ethscribe/version'
|
79
|
+
require_relative 'ethscribe/api'
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
module Ethscribe
|
84
|
+
#############
|
85
|
+
## add more convenience alias - why? why not?
|
86
|
+
API = Api
|
87
|
+
end # module Ethscribe
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
# say hello
|
92
|
+
puts Ethscribe.banner ## if defined?($RUBYCOCOS_DEBUG) && $RUBCOCOS_DEBUG
|
3
93
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethscribe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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-
|
11
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocos
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rdoc
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,7 +58,7 @@ dependencies:
|
|
44
58
|
- - "~>"
|
45
59
|
- !ruby/object:Gem::Version
|
46
60
|
version: '4.0'
|
47
|
-
description: ethscribe
|
61
|
+
description: ethscribe - inscription (ethscription calldata) api wrapper & helpers
|
48
62
|
for Ethereum & co.
|
49
63
|
email: gerald.bauer@gmail.com
|
50
64
|
executables: []
|
@@ -59,6 +73,8 @@ files:
|
|
59
73
|
- README.md
|
60
74
|
- Rakefile
|
61
75
|
- lib/ethscribe.rb
|
76
|
+
- lib/ethscribe/api.rb
|
77
|
+
- lib/ethscribe/version.rb
|
62
78
|
homepage: https://github.com/s6ruby/rubidity
|
63
79
|
licenses:
|
64
80
|
- Public Domain
|
@@ -83,6 +99,6 @@ requirements: []
|
|
83
99
|
rubygems_version: 3.4.10
|
84
100
|
signing_key:
|
85
101
|
specification_version: 4
|
86
|
-
summary: ethscribe
|
102
|
+
summary: ethscribe - inscription (ethscription calldata) api wrapper & helpers for
|
87
103
|
Ethereum & co.
|
88
104
|
test_files: []
|