stellar-sdk 0.27.0 → 0.28.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: 4956394163d9ef780494428a310af5d3a80b2b63caba45be39e42e55b7557298
4
- data.tar.gz: 482c2efc7b68b1348551a08f9e8ab4dc17e723ae86b9dad76fd1bc94e42f72d2
3
+ metadata.gz: 16f2babbd6e3fd516c62f8ff0fb2fe264e335dae7bb051721a3f4fefb5195f4d
4
+ data.tar.gz: dd0d6b370c14ca38ae09a7bcfcfaccfc1214af2115308c9f2574f84f133a85a4
5
5
  SHA512:
6
- metadata.gz: 34dfeb9b87ce27716b0d97a17ef42ff91d8b1bb34bdfecdea9797ddc1f840eaa1c88957c42e39ef4ca41bdf17e0ec7b5a64b30f8a608ed3173f2e818f5c2013c
7
- data.tar.gz: 48e93b269189a67e654ca59d83a0c697ed4388a418f668e67857a6026e1448e5766e006ccadfadb3993a1adc59ab629426336000acc651d32f41a0352ac9d8f3
6
+ metadata.gz: 5b4ce731f7be3b66a5d1cd0f8a03ebb8ba5ffbcb7c55b0fdc9a45189edd95f2d288a3047d603e222e06f69e7079c418c27bc0b82c3bcd0f25f182573630cba67
7
+ data.tar.gz: c74630a8193bc6bfd3bd2ce730491c0de96f4b7b49b9b1523d02b191f9c2358cfe1c6ca7e286db28ded3680c6e8d110c003249928f86682cec6da3e4fc91b35d
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [0.28.0](https://www.github.com/astroband/ruby-stellar-sdk/compare/v0.27.0...v0.28.0) (2021-07-17)
9
+
10
+ ### Changed
11
+ * `Stellar::Account` class is now part of `stellar-base` gem
12
+ * `Stellar::Account.lookup` is deprecated, use `Stellar::Federation.lookup` instead
13
+
8
14
  ## [0.27.0](https://github.com/astroband/ruby-stellar-sdk/compare/v0.26.0...v0.27.0) (2021-05-08)
9
15
  - No changes
10
16
 
data/lib/stellar-sdk.rb CHANGED
@@ -5,9 +5,9 @@ module Stellar
5
5
  VERSION = ::Stellar::VERSION
6
6
  end
7
7
 
8
- autoload :Account
9
8
  autoload :Amount
10
9
  autoload :Client
10
+ autoload :Federation
11
11
  autoload :SEP10
12
12
 
13
13
  module Horizon
@@ -19,3 +19,5 @@ module Stellar
19
19
 
20
20
  autoload :TransactionPage
21
21
  end
22
+
23
+ require_relative "stellar/compat"
@@ -0,0 +1,4 @@
1
+ class << Stellar::Account
2
+ delegate :lookup, to: Stellar::Federation
3
+ deprecate deprecator: Stellar::Deprecation, lookup: "Use `Stellar::Federation.lookup` method"
4
+ end
@@ -0,0 +1,51 @@
1
+ require "toml-rb"
2
+ require "uri"
3
+ require "faraday"
4
+ require "json"
5
+
6
+ module Stellar
7
+ class Federation
8
+ def self.lookup(federated_name)
9
+ _, domain = federated_name.split("*")
10
+ if domain.nil?
11
+ raise InvalidFederationAddress.new
12
+ end
13
+
14
+ domain_req = Faraday.new("https://#{domain}/.well-known/stellar.toml").get
15
+
16
+ unless domain_req.status == 200
17
+ raise InvalidStellarDomain, "Domain does not contain stellar.toml file"
18
+ end
19
+
20
+ fed_server_url = TomlRB.parse(domain_req.body)["FEDERATION_SERVER"]
21
+ if fed_server_url.nil?
22
+ raise InvalidStellarTOML, "Invalid Stellar TOML file"
23
+ end
24
+
25
+ unless fed_server_url&.match?(URI::DEFAULT_PARSER.make_regexp)
26
+ raise InvalidFederationURL, "Invalid Federation Server URL"
27
+ end
28
+
29
+ lookup_req = Faraday.new(fed_server_url).get { |req|
30
+ req.params[:q] = federated_name
31
+ req.params[:type] = "name"
32
+ }
33
+
34
+ unless lookup_req.status == 200
35
+ raise AccountNotFound, "Account not found"
36
+ end
37
+
38
+ JSON.parse(lookup_req.body)["account_id"]
39
+ end
40
+ end
41
+
42
+ class AccountNotFound < StandardError; end
43
+
44
+ class InvalidStellarTOML < StandardError; end
45
+
46
+ class InvalidFederationAddress < StandardError; end
47
+
48
+ class InvalidStellarDomain < StandardError; end
49
+
50
+ class InvalidFederationURL < StandardError; end
51
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  - Sergey Nebolsin
9
9
  - Timur Ramazanov
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-05-09 00:00:00.000000000 Z
13
+ date: 2021-07-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: stellar-base
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.27.0
21
+ version: 0.28.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.27.0
28
+ version: 0.28.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: activesupport
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -148,8 +148,8 @@ dependencies:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
150
  version: '3.9'
151
- description:
152
- email:
151
+ description:
152
+ email:
153
153
  executables: []
154
154
  extensions: []
155
155
  extra_rdoc_files:
@@ -161,9 +161,10 @@ files:
161
161
  - LICENSE
162
162
  - README.md
163
163
  - lib/stellar-sdk.rb
164
- - lib/stellar/account.rb
165
164
  - lib/stellar/amount.rb
166
165
  - lib/stellar/client.rb
166
+ - lib/stellar/compat.rb
167
+ - lib/stellar/federation.rb
167
168
  - lib/stellar/horizon/problem.rb
168
169
  - lib/stellar/sep10.rb
169
170
  - lib/stellar/transaction_page.rb
@@ -172,12 +173,12 @@ licenses:
172
173
  - Apache-2.0
173
174
  metadata:
174
175
  bug_tracker_uri: https://github.com/astroband/ruby-stellar-sdk/issues
175
- changelog_uri: https://github.com/astroband/ruby-stellar-sdk/blob/v0.27.0/sdk/CHANGELOG.md
176
- documentation_uri: https://rubydoc.info/gems/stellar-sdk/0.27.0/
176
+ changelog_uri: https://github.com/astroband/ruby-stellar-sdk/blob/v0.28.0/sdk/CHANGELOG.md
177
+ documentation_uri: https://rubydoc.info/gems/stellar-sdk/0.28.0/
177
178
  github_repo: ssh://github.com/astroband/ruby-stellar-sdk
178
179
  homepage_uri: https://github.com/astroband/ruby-stellar-sdk/tree/main/sdk
179
- source_code_uri: https://github.com/astroband/ruby-stellar-sdk/tree/v0.27.0/sdk
180
- post_install_message:
180
+ source_code_uri: https://github.com/astroband/ruby-stellar-sdk/tree/v0.28.0/sdk
181
+ post_install_message:
181
182
  rdoc_options: []
182
183
  require_paths:
183
184
  - lib
@@ -192,8 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
193
  - !ruby/object:Gem::Version
193
194
  version: '0'
194
195
  requirements: []
195
- rubygems_version: 3.2.16
196
- signing_key:
196
+ rubygems_version: 3.2.22
197
+ signing_key:
197
198
  specification_version: 4
198
199
  summary: Stellar client library
199
200
  test_files: []
@@ -1,89 +0,0 @@
1
- require "toml-rb"
2
- require "uri"
3
- require "faraday"
4
- require "json"
5
-
6
- module Stellar
7
- class Account
8
- delegate :address, to: :keypair
9
-
10
- def self.random
11
- keypair = Stellar::KeyPair.random
12
- new(keypair)
13
- end
14
-
15
- def self.from_seed(seed)
16
- keypair = Stellar::KeyPair.from_seed(seed)
17
- new(keypair)
18
- end
19
-
20
- def self.from_address(address)
21
- keypair = Stellar::KeyPair.from_address(address)
22
- new(keypair)
23
- end
24
-
25
- def self.lookup(federated_name)
26
- _, domain = federated_name.split("*")
27
- if domain.nil?
28
- raise InvalidFederationAddress.new
29
- end
30
-
31
- domain_req = Faraday.new("https://#{domain}/.well-known/stellar.toml").get
32
-
33
- unless domain_req.status == 200
34
- raise InvalidStellarDomain.new("Domain does not contain stellar.toml file")
35
- end
36
-
37
- fed_server_url = TomlRB.parse(domain_req.body)["FEDERATION_SERVER"]
38
- if fed_server_url.nil?
39
- raise InvalidStellarTOML.new("Invalid Stellar TOML file")
40
- end
41
-
42
- unless fed_server_url&.match?(URI::DEFAULT_PARSER.make_regexp)
43
- raise InvalidFederationURL.new("Invalid Federation Server URL")
44
- end
45
-
46
- lookup_req = Faraday.new(fed_server_url).get { |req|
47
- req.params[:q] = federated_name
48
- req.params[:type] = "name"
49
- }
50
-
51
- unless lookup_req.status == 200
52
- raise AccountNotFound.new("Account not found")
53
- end
54
-
55
- JSON.parse(lookup_req.body)["account_id"]
56
- end
57
-
58
- def self.master
59
- keypair = Stellar::KeyPair.from_raw_seed("allmylifemyhearthasbeensearching")
60
- new(keypair)
61
- end
62
-
63
- attr_reader :keypair
64
-
65
- # @param [Stellar::KeyPair] keypair
66
- def initialize(keypair)
67
- @keypair = keypair
68
- end
69
-
70
- def to_keypair
71
- keypair
72
- end
73
- end
74
-
75
- class AccountNotFound < StandardError
76
- end
77
-
78
- class InvalidStellarTOML < StandardError
79
- end
80
-
81
- class InvalidFederationAddress < StandardError
82
- end
83
-
84
- class InvalidStellarDomain < StandardError
85
- end
86
-
87
- class InvalidFederationURL < StandardError
88
- end
89
- end