sequence-sdk 1.4 → 1.5
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 +5 -5
- data/README.md +1 -1
- data/lib/sequence.rb +2 -0
- data/lib/sequence/account.rb +28 -2
- data/lib/sequence/action.rb +2 -0
- data/lib/sequence/asset.rb +2 -0
- data/lib/sequence/balance.rb +2 -0
- data/lib/sequence/client.rb +8 -0
- data/lib/sequence/client_module.rb +2 -0
- data/lib/sequence/contract.rb +2 -0
- data/lib/sequence/dev_utils.rb +2 -0
- data/lib/sequence/errors.rb +4 -2
- data/lib/sequence/feed.rb +144 -0
- data/lib/sequence/flavor.rb +20 -3
- data/lib/sequence/http_wrapper.rb +4 -1
- data/lib/sequence/key.rb +2 -0
- data/lib/sequence/page.rb +2 -0
- data/lib/sequence/query.rb +7 -5
- data/lib/sequence/response_object.rb +28 -9
- data/lib/sequence/session.rb +26 -11
- data/lib/sequence/stats.rb +2 -0
- data/lib/sequence/token.rb +2 -0
- data/lib/sequence/transaction.rb +4 -101
- data/lib/sequence/validations.rb +2 -0
- data/lib/sequence/version.rb +3 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1390aa5fd0879b5d216f3eef77fe3f9c1c452202c8c8b8729436e9a959a8ca90
|
4
|
+
data.tar.gz: decf43bb5970ae517f08d5669bacc5c8b0f6a946904b9282e7a1170bbd3623ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60b8845cedc62f49b4fabdae7e24e5ea6c3e4049907e62f92ec6a58f81392a76ecbcb7d9ccd4168392f729b7d0acfddd48d405c79bf728863955d817df2101cd
|
7
|
+
data.tar.gz: a3f2541a5b326ce59b0457c97c2f7fbf0dbc5aaec0f1ad525bceee7ad2e43bbc58e37223206744256a2c172823e74525b01191969d0f81fb3264faa15ea7d740
|
data/README.md
CHANGED
data/lib/sequence.rb
CHANGED
data/lib/sequence/account.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './client_module'
|
2
4
|
require_relative './errors'
|
3
5
|
require_relative './query'
|
@@ -17,7 +19,14 @@ module Sequence
|
|
17
19
|
# @return [String]
|
18
20
|
attrib :alias
|
19
21
|
|
22
|
+
# @!attribute [r] key_ids
|
23
|
+
# The set of key IDs used for signing transactions that spend from the
|
24
|
+
# account.
|
25
|
+
# @return [Array<String>]
|
26
|
+
attrib(:key_ids)
|
27
|
+
|
20
28
|
# @!attribute [r] keys
|
29
|
+
# Deprecated. Use {#key_ids} instead.
|
21
30
|
# The set of keys used for signing transactions that spend from the
|
22
31
|
# account.
|
23
32
|
# @return [Array<Key>]
|
@@ -48,7 +57,10 @@ module Sequence
|
|
48
57
|
# @option opts [String] alias
|
49
58
|
# Deprecated. Use :id instead.
|
50
59
|
# Unique, user-specified identifier.
|
60
|
+
# @option opts [Array<String>] key_ids
|
61
|
+
# The key IDs used for signing transactions that spend from the account.
|
51
62
|
# @option opts [Array<Hash>, Array<Sequence::Key>] keys
|
63
|
+
# Deprecated. Use :key_ids instead.
|
52
64
|
# The keys used for signing transactions that spend from the account. A
|
53
65
|
# key can be either a key object, or a hash containing either an `id` or
|
54
66
|
# `alias` field.
|
@@ -59,8 +71,22 @@ module Sequence
|
|
59
71
|
# User-specified key-value data describing the account.
|
60
72
|
# @return [Account]
|
61
73
|
def create(opts = {})
|
62
|
-
validate_inclusion_of!(
|
63
|
-
|
74
|
+
validate_inclusion_of!(
|
75
|
+
opts,
|
76
|
+
:alias,
|
77
|
+
:id,
|
78
|
+
:key_ids,
|
79
|
+
:keys,
|
80
|
+
:quorum,
|
81
|
+
:tags,
|
82
|
+
)
|
83
|
+
if (opts[:key_ids].nil? || opts[:key_ids].empty?) &&
|
84
|
+
(opts[:keys].nil? || opts[:keys].empty?)
|
85
|
+
raise(
|
86
|
+
ArgumentError,
|
87
|
+
':key_ids or :keys (but not both) must be provided',
|
88
|
+
)
|
89
|
+
end
|
64
90
|
Account.new(client.session.request('create-account', opts))
|
65
91
|
end
|
66
92
|
|
data/lib/sequence/action.rb
CHANGED
data/lib/sequence/asset.rb
CHANGED
data/lib/sequence/balance.rb
CHANGED
data/lib/sequence/client.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './account'
|
2
4
|
require_relative './action'
|
3
5
|
require_relative './asset'
|
4
6
|
require_relative './balance'
|
5
7
|
require_relative './contract'
|
6
8
|
require_relative './dev_utils'
|
9
|
+
require_relative './feed'
|
7
10
|
require_relative './flavor'
|
8
11
|
require_relative './key'
|
9
12
|
require_relative './stats'
|
@@ -87,6 +90,11 @@ module Sequence
|
|
87
90
|
@transactions ||= Transaction::ClientModule.new(self)
|
88
91
|
end
|
89
92
|
|
93
|
+
# @return [Feed::ClientModule]
|
94
|
+
def feeds
|
95
|
+
@feeds ||= Feed::ClientModule.new(self)
|
96
|
+
end
|
97
|
+
|
90
98
|
# @return [Contract::ClientModule]
|
91
99
|
def contracts
|
92
100
|
@contracts ||= Contract::ClientModule.new(self)
|
data/lib/sequence/contract.rb
CHANGED
data/lib/sequence/dev_utils.rb
CHANGED
data/lib/sequence/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Sequence
|
2
4
|
# Base class for all errors raised by the Sequence SDK.
|
3
5
|
class BaseError < StandardError; end
|
@@ -16,8 +18,8 @@ module Sequence
|
|
16
18
|
end
|
17
19
|
|
18
20
|
# JSONError should be very rare, and will only arise if there is a bug in the
|
19
|
-
# Sequence API, or if the upstream server is spoofing common Sequence API
|
20
|
-
# headers.
|
21
|
+
# Sequence API, or if the upstream server is spoofing common Sequence API
|
22
|
+
# response headers.
|
21
23
|
class JSONError < BaseError
|
22
24
|
attr_accessor :request_id
|
23
25
|
attr_accessor :response
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
require_relative './client_module'
|
6
|
+
require_relative './http_wrapper'
|
7
|
+
require_relative './query'
|
8
|
+
require_relative './response_object'
|
9
|
+
|
10
|
+
module Sequence
|
11
|
+
class Feed < Sequence::ResponseObject
|
12
|
+
# @!attribute [r] id
|
13
|
+
# Unique feed identifier.
|
14
|
+
# @return [String]
|
15
|
+
attrib :id
|
16
|
+
|
17
|
+
# @!attribute [r] type
|
18
|
+
# Type of feed, "action" or "transaction".
|
19
|
+
# @return [String]
|
20
|
+
attrib :type
|
21
|
+
|
22
|
+
# @!attribute [r] filter
|
23
|
+
# The query filter used to select matching items.
|
24
|
+
# @return [String]
|
25
|
+
attrib :filter
|
26
|
+
|
27
|
+
# @!attribute [r] filter_params
|
28
|
+
# A list of values that will be interpolated into the filter expression.
|
29
|
+
# @return [Array<String|Integer>]
|
30
|
+
attrib :filter_params
|
31
|
+
|
32
|
+
# @!attribute [r] cursor
|
33
|
+
# The position where the next call to consume should begin.
|
34
|
+
# @return [String]
|
35
|
+
attrib :cursor
|
36
|
+
|
37
|
+
def initialize(raw_attribs, base_session)
|
38
|
+
super(raw_attribs)
|
39
|
+
|
40
|
+
# The consume/ack cycle should run on its own thread, so make a copy of
|
41
|
+
# the base connection so this feed has an exclusive HTTP connection.
|
42
|
+
@consume_session = base_session.dup
|
43
|
+
end
|
44
|
+
|
45
|
+
# Consume yields successive items in a feed, waiting until at
|
46
|
+
# least one is available (or the call times out). Since it waits
|
47
|
+
# it may be desirable to call consume in its own thread.
|
48
|
+
# @param [Fixnum] timeout value in seconds
|
49
|
+
# @yieldparam object [Action, Transaction]
|
50
|
+
# @return [void]
|
51
|
+
def consume
|
52
|
+
loop do
|
53
|
+
page = @consume_session.request('stream-feed-items', id: id)
|
54
|
+
|
55
|
+
page['items'].each_with_index do |item, index|
|
56
|
+
@next_cursor = page['cursors'][index]
|
57
|
+
if type == 'action'
|
58
|
+
yield Action.new(item)
|
59
|
+
else
|
60
|
+
yield Transaction.new(item)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Ack ("acknowledge") saves a feed's position so that a future
|
67
|
+
# call to consume picks up where the last one left off. Without
|
68
|
+
# ack, some of the same items may be redelivered by
|
69
|
+
# consume. Consume does its own internal acks from time to time.
|
70
|
+
# @return [void]
|
71
|
+
def ack
|
72
|
+
if @next_cursor
|
73
|
+
@consume_session.request(
|
74
|
+
'ack-feed',
|
75
|
+
id: id,
|
76
|
+
cursor: @next_cursor,
|
77
|
+
previous_cursor: cursor,
|
78
|
+
)
|
79
|
+
self.cursor = @next_cursor
|
80
|
+
@next_cursor = nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class ClientModule < Sequence::ClientModule
|
85
|
+
# @param [Hash] opts Parameters for creating a Feed.
|
86
|
+
# @option opts [String] id A unique id for the feed.
|
87
|
+
# @option opts [String] type The type of the feed: "action" or
|
88
|
+
# "transaction".
|
89
|
+
# @option opts [String] filter A valid filter string. The feed will be
|
90
|
+
# composed of items that match the filter.
|
91
|
+
# @option opts [Array<String|Integer>] filter_params A list of values that
|
92
|
+
# will be interpolated into the filter expression.
|
93
|
+
# @return [Feed] Newly created feed.
|
94
|
+
def create(opts = {})
|
95
|
+
validate_inclusion_of!(
|
96
|
+
opts,
|
97
|
+
:id,
|
98
|
+
:type,
|
99
|
+
:filter,
|
100
|
+
:filter_params,
|
101
|
+
)
|
102
|
+
validate_required!(opts, :type)
|
103
|
+
if opts[:type] != 'action' && opts[:type] != 'transaction'
|
104
|
+
raise ArgumentError, ':type must equal action or transaction'
|
105
|
+
end
|
106
|
+
Feed.new(client.session.request('create-feed', opts), client.session)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Get single feed given an id.
|
110
|
+
# @param [Hash] opts Parameters to get single feed.
|
111
|
+
# @option opts [String] id The unique ID of a feed.
|
112
|
+
# @return [Feed] Requested feed object.
|
113
|
+
def get(opts = {})
|
114
|
+
validate_required!(opts, :id)
|
115
|
+
Feed.new(client.session.request('get-feed', opts), client.session)
|
116
|
+
end
|
117
|
+
|
118
|
+
# @param [Hash] opts
|
119
|
+
# @option opts [String] id The unique ID of a feed.
|
120
|
+
# @return [void]
|
121
|
+
def delete(opts = {})
|
122
|
+
validate_required!(opts, :id)
|
123
|
+
client.session.request('delete-feed', opts)
|
124
|
+
nil
|
125
|
+
end
|
126
|
+
|
127
|
+
# Executes a query, returning an enumerable over individual feeds.
|
128
|
+
# @return [Query]
|
129
|
+
def list
|
130
|
+
Query.new(client)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
class Query < Sequence::Query
|
135
|
+
def fetch(query)
|
136
|
+
client.session.request('list-feeds', query)
|
137
|
+
end
|
138
|
+
|
139
|
+
def translate(raw)
|
140
|
+
Feed.new(raw, client.session)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/lib/sequence/flavor.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'securerandom'
|
2
4
|
|
3
5
|
require_relative './client_module'
|
@@ -13,7 +15,14 @@ module Sequence
|
|
13
15
|
# @return [String]
|
14
16
|
attrib :id
|
15
17
|
|
18
|
+
# @!attribute [r] key_ids
|
19
|
+
# The set of key IDs used to sign transactions that issue tokens of the
|
20
|
+
# flavor.
|
21
|
+
# @return [Array<String>]
|
22
|
+
attrib(:key_ids)
|
23
|
+
|
16
24
|
# @!attribute [r] keys
|
25
|
+
# Deprecated. Use {#key_ids} instead.
|
17
26
|
# The set of keys used to sign transactions that issue tokens of the
|
18
27
|
# flavor.
|
19
28
|
# @return [Array<Key>]
|
@@ -40,7 +49,11 @@ module Sequence
|
|
40
49
|
# Options hash
|
41
50
|
# @option opts [String] id
|
42
51
|
# Unique, user-specified identifier.
|
52
|
+
# @option opts [Array<String>] key_ids
|
53
|
+
# The set of key IDs used for signing transactions that issue tokens of
|
54
|
+
# the flavor.
|
43
55
|
# @option opts [Array<Hash>, Array<Sequence::Key>] keys
|
56
|
+
# Deprecated. Use :key_ids instead.
|
44
57
|
# The set of keys used for signing transactions that issue tokens of the
|
45
58
|
# flavor. A key can be either a key object, or a hash containing an
|
46
59
|
# `id` field.
|
@@ -51,9 +64,13 @@ module Sequence
|
|
51
64
|
# User-specified key-value data describing the flavor.
|
52
65
|
# @return [Flavor]
|
53
66
|
def create(opts = {})
|
54
|
-
validate_inclusion_of!(opts, :id, :keys, :quorum, :tags)
|
55
|
-
if opts[:
|
56
|
-
|
67
|
+
validate_inclusion_of!(opts, :id, :key_ids, :keys, :quorum, :tags)
|
68
|
+
if (opts[:key_ids].nil? || opts[:key_ids].empty?) &&
|
69
|
+
(opts[:keys].nil? || opts[:keys].empty?)
|
70
|
+
raise(
|
71
|
+
ArgumentError,
|
72
|
+
':key_ids or :keys (but not both) must be provided',
|
73
|
+
)
|
57
74
|
end
|
58
75
|
Flavor.new(client.session.request('create-flavor', opts))
|
59
76
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'net/http'
|
2
4
|
require 'net/https'
|
3
5
|
require 'openssl'
|
@@ -53,6 +55,7 @@ module Sequence
|
|
53
55
|
req['Content-Type'] = 'application/json'
|
54
56
|
req['Id'] = attempt_id
|
55
57
|
req['Idempotency-Key'] = idempotency_key
|
58
|
+
req['Name-Set'] = 'snake'
|
56
59
|
req['User-Agent'] = 'chain-sdk-ruby/' + Sequence::VERSION
|
57
60
|
if !@macaroon.nil? && !@dis_macaroon.nil?
|
58
61
|
req['Macaroon'] = @macaroon
|
@@ -82,7 +85,7 @@ module Sequence
|
|
82
85
|
end
|
83
86
|
end
|
84
87
|
if status / 100 != 2
|
85
|
-
|
88
|
+
status == 401 ? klass = UnauthorizedError : klass = APIError
|
86
89
|
raise klass.new(parsed_body, response)
|
87
90
|
end
|
88
91
|
|
data/lib/sequence/key.rb
CHANGED
data/lib/sequence/page.rb
CHANGED
data/lib/sequence/query.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './page'
|
2
4
|
|
3
5
|
module Sequence
|
@@ -25,24 +27,24 @@ module Sequence
|
|
25
27
|
# @return [void]
|
26
28
|
def each
|
27
29
|
pages.each do |page|
|
28
|
-
page.items.each do |item
|
30
|
+
page.items.each do |item|
|
29
31
|
yield item
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
# @private
|
35
|
-
def fetch(
|
37
|
+
def fetch(_query)
|
36
38
|
raise NotImplementedError
|
37
39
|
end
|
38
40
|
|
39
41
|
# Overwrite to translate API response data to a different Ruby object.
|
40
42
|
# @private
|
41
|
-
def translate(
|
43
|
+
def translate(_response_object)
|
42
44
|
raise NotImplementedError
|
43
45
|
end
|
44
46
|
|
45
|
-
|
47
|
+
alias all to_a
|
46
48
|
|
47
49
|
# @private
|
48
50
|
def pages
|
@@ -90,7 +92,7 @@ module Sequence
|
|
90
92
|
Page.new(@fetch.call(@query), @translate)
|
91
93
|
end
|
92
94
|
|
93
|
-
|
95
|
+
alias all to_a
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'time'
|
3
5
|
|
@@ -11,16 +13,14 @@ module Sequence
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def to_h
|
14
|
-
self.class.attrib_opts.keys.
|
16
|
+
self.class.attrib_opts.keys.each_with_object({}) do |name, memo|
|
15
17
|
memo[name] = instance_variable_get("@#{name}")
|
16
|
-
memo
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
def to_json(
|
21
|
-
h = to_h.
|
21
|
+
def to_json(_opts = nil)
|
22
|
+
h = to_h.each_with_object({}) do |(k, v), memo|
|
22
23
|
memo[k] = self.class.detranslate(k, v)
|
23
|
-
memo
|
24
24
|
end
|
25
25
|
|
26
26
|
h.to_json
|
@@ -28,14 +28,18 @@ module Sequence
|
|
28
28
|
|
29
29
|
def [](attrib_name)
|
30
30
|
attrib_name = attrib_name.to_sym
|
31
|
-
|
31
|
+
unless self.class.attrib_opts.key?(attrib_name)
|
32
|
+
raise KeyError, "key not found: #{attrib_name}"
|
33
|
+
end
|
32
34
|
|
33
35
|
instance_variable_get "@#{attrib_name}"
|
34
36
|
end
|
35
37
|
|
36
38
|
def []=(attrib_name, value)
|
37
39
|
attrib_name = attrib_name.to_sym
|
38
|
-
|
40
|
+
unless self.class.attrib_opts.key?(attrib_name)
|
41
|
+
raise KeyError, "key not found: #{attrib_name}"
|
42
|
+
end
|
39
43
|
|
40
44
|
instance_variable_set "@#{attrib_name}", value
|
41
45
|
end
|
@@ -68,7 +72,7 @@ module Sequence
|
|
68
72
|
|
69
73
|
begin
|
70
74
|
opts[:translate].call raw_value
|
71
|
-
rescue => e
|
75
|
+
rescue StandardError => e
|
72
76
|
raise TranslateError.new(attrib_name, raw_value, e)
|
73
77
|
end
|
74
78
|
end
|
@@ -80,7 +84,7 @@ module Sequence
|
|
80
84
|
if opts[:rfc3339_time]
|
81
85
|
begin
|
82
86
|
return raw_value.to_datetime.rfc3339
|
83
|
-
rescue => e
|
87
|
+
rescue StandardError => e
|
84
88
|
raise DetranslateError.new(attrib_name, raw_value, e)
|
85
89
|
end
|
86
90
|
end
|
@@ -97,22 +101,37 @@ module Sequence
|
|
97
101
|
@data[key]
|
98
102
|
end
|
99
103
|
|
104
|
+
def to_json(_opts = nil)
|
105
|
+
@data.to_json
|
106
|
+
end
|
107
|
+
|
108
|
+
# A snapshot of the actions's tags at the time of action creation
|
109
|
+
# @return [Hash]
|
100
110
|
def action_tags
|
101
111
|
@data['action_tags']
|
102
112
|
end
|
103
113
|
|
114
|
+
# A snapshot of the destination account's tags at the time of action
|
115
|
+
# creation
|
116
|
+
# @return [Hash]
|
104
117
|
def destination_account_tags
|
105
118
|
@data['destination_account_tags']
|
106
119
|
end
|
107
120
|
|
121
|
+
# A snapshot of the flavor's tags at the time of action creation
|
122
|
+
# @return [Hash]
|
108
123
|
def flavor_tags
|
109
124
|
@data['flavor_tags']
|
110
125
|
end
|
111
126
|
|
127
|
+
# A snapshot of the source account's tags at the time of action creation
|
128
|
+
# @return [Hash]
|
112
129
|
def source_account_tags
|
113
130
|
@data['source_account_tags']
|
114
131
|
end
|
115
132
|
|
133
|
+
# A snapshot of the token's tags at the time of action creation
|
134
|
+
# @return [Hash]
|
116
135
|
def token_tags
|
117
136
|
@data['token_tags']
|
118
137
|
end
|
data/lib/sequence/session.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
require_relative './http_wrapper'
|
@@ -9,8 +11,14 @@ module Sequence
|
|
9
11
|
class Session
|
10
12
|
def initialize(opts)
|
11
13
|
@opts = opts
|
12
|
-
@ledger = @opts[:ledger_name] || raise(
|
13
|
-
|
14
|
+
@ledger = @opts[:ledger_name] || raise(
|
15
|
+
ArgumentError,
|
16
|
+
'missing ledger_name',
|
17
|
+
)
|
18
|
+
@macaroon = @opts[:credential] || raise(
|
19
|
+
ArgumentError,
|
20
|
+
'missing credential',
|
21
|
+
)
|
14
22
|
|
15
23
|
# Start at 0 to trigger an immediate refresh
|
16
24
|
@refresh_at = 0
|
@@ -22,11 +30,14 @@ module Sequence
|
|
22
30
|
# new discharge macaroon.
|
23
31
|
@refresh_method = @opts[:refresh_method]
|
24
32
|
if @refresh_method
|
25
|
-
|
26
|
-
raise
|
33
|
+
unless @refresh_method.respond_to?(:call)
|
34
|
+
raise ArgumentError, 'refresh_method is not a lambda'
|
27
35
|
end
|
28
36
|
if @refresh_method.arity != 1
|
29
|
-
raise(
|
37
|
+
raise(
|
38
|
+
ArgumentError,
|
39
|
+
'refresh_method must take 1 argument. (the macaroon)',
|
40
|
+
)
|
30
41
|
end
|
31
42
|
end
|
32
43
|
|
@@ -54,8 +65,8 @@ module Sequence
|
|
54
65
|
# a Sequence load balancer. This error will be retried by
|
55
66
|
# HttpWrapper.post.
|
56
67
|
req_id = response['Chain-Request-ID']
|
57
|
-
unless req_id.is_a?(String) && req_id.
|
58
|
-
raise InvalidRequestIDError
|
68
|
+
unless req_id.is_a?(String) && !req_id.empty?
|
69
|
+
raise InvalidRequestIDError, response
|
59
70
|
end
|
60
71
|
end
|
61
72
|
end
|
@@ -63,17 +74,21 @@ module Sequence
|
|
63
74
|
private
|
64
75
|
|
65
76
|
def ledger_url(path)
|
66
|
-
path = path[1..-1] if path.start_with?(
|
77
|
+
path = path[1..-1] if path.start_with?('/')
|
67
78
|
"/#{@team_name}/#{@ledger}/#{path}"
|
68
79
|
end
|
69
80
|
|
70
81
|
def refresh!(id)
|
71
82
|
return if @refresh_at > Time.now.to_i
|
72
83
|
|
73
|
-
|
74
|
-
@refresh_method.call(@macaroon)
|
84
|
+
if @refresh_method
|
85
|
+
result = @refresh_method.call(@macaroon)
|
75
86
|
else
|
76
|
-
@session_api.post(
|
87
|
+
result = @session_api.post(
|
88
|
+
id,
|
89
|
+
'/sessions/validate',
|
90
|
+
macaroon: @macaroon,
|
91
|
+
)[:parsed_body]
|
77
92
|
end
|
78
93
|
|
79
94
|
@team_name = result['team_name']
|
data/lib/sequence/stats.rb
CHANGED
data/lib/sequence/token.rb
CHANGED
data/lib/sequence/transaction.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'securerandom'
|
2
4
|
|
3
5
|
require_relative './client_module'
|
@@ -25,13 +27,8 @@ module Sequence
|
|
25
27
|
# @return [Integer]
|
26
28
|
attrib :sequence_number
|
27
29
|
|
28
|
-
# @!attribute [r] token_tags
|
29
|
-
# User specified, unstructured data embedded within a token
|
30
|
-
# (possibly null).
|
31
|
-
# @return [Hash]
|
32
|
-
attrib :token_tags
|
33
|
-
|
34
30
|
# @!attribute [r] reference_data
|
31
|
+
# Deprecated. Use {Sequence::Action#tags} instead.
|
35
32
|
# User-specified key-value data embedded into the transaction.
|
36
33
|
# @return [Hash]
|
37
34
|
attrib :reference_data
|
@@ -112,105 +109,11 @@ module Sequence
|
|
112
109
|
end
|
113
110
|
end
|
114
111
|
|
115
|
-
# An action taken by a transaction.
|
116
|
-
class Action < ResponseObject
|
117
|
-
# @!attribute [r] type
|
118
|
-
# The type of the action. Possible values are "issue", "transfer" and
|
119
|
-
# "retire".
|
120
|
-
# @return [String]
|
121
|
-
attrib :type
|
122
|
-
|
123
|
-
# @!attribute [r] flavor_id
|
124
|
-
# The id of the action's flavor.
|
125
|
-
# @return [String]
|
126
|
-
attrib :flavor_id
|
127
|
-
|
128
|
-
# @!attribute [r] snapshot
|
129
|
-
# A copy of the associated tags (flavor, source account, destination
|
130
|
-
# account, action, and token) as they existed at the time of the
|
131
|
-
# transaction.
|
132
|
-
# @return [Hash]
|
133
|
-
attrib :snapshot, snapshot: true
|
134
|
-
|
135
|
-
# @!attribute [r] asset_id
|
136
|
-
# Deprecated. Use {#flavor_id} instead.
|
137
|
-
# The id of the action's asset.
|
138
|
-
# @return [String]
|
139
|
-
attrib :asset_id
|
140
|
-
|
141
|
-
# @!attribute [r] asset_alias
|
142
|
-
# Deprecated. Use {#flavor_id} instead.
|
143
|
-
# The alias of the action's asset.
|
144
|
-
# @return [String]
|
145
|
-
attrib :asset_alias
|
146
|
-
|
147
|
-
# @!attribute [r] asset_tags
|
148
|
-
# Deprecated. Use {#snapshot} instead.
|
149
|
-
# The tags of the action's asset.
|
150
|
-
# @return [Hash]
|
151
|
-
attrib :asset_tags
|
152
|
-
|
153
|
-
# @!attribute [r] amount
|
154
|
-
# The number of flavor units issued, transferred, or retired.
|
155
|
-
# @return [Integer]
|
156
|
-
attrib :amount
|
157
|
-
|
158
|
-
# @!attribute [r] source_account_id
|
159
|
-
# The ID of the account serving as the source of flavor units. Null for
|
160
|
-
# issuances.
|
161
|
-
# @return [String]
|
162
|
-
attrib :source_account_id
|
163
|
-
|
164
|
-
# @!attribute [r] source_account_alias
|
165
|
-
# Deprecated. Use {#source_account_id} instead.
|
166
|
-
# The alias of the account serving as the source of asset units.
|
167
|
-
# Null for issuances.
|
168
|
-
# @return [String]
|
169
|
-
attrib :source_account_alias
|
170
|
-
|
171
|
-
# @!attribute [r] source_account_tags
|
172
|
-
# Deprecated. Use {#snapshot} instead.
|
173
|
-
# The tags of the account serving as the source of flavor units.
|
174
|
-
# Null for issuances.
|
175
|
-
# @return [String]
|
176
|
-
attrib :source_account_tags
|
177
|
-
|
178
|
-
# @!attribute [r] destination_account_id
|
179
|
-
# The ID of the account receiving the flavor units.
|
180
|
-
# Null for retirements.
|
181
|
-
# @return [String]
|
182
|
-
attrib :destination_account_id
|
183
|
-
|
184
|
-
# @!attribute [r] destination_account_alias
|
185
|
-
# Deprecated. Use {#destination_account_id} instead.
|
186
|
-
# The alias of the account receiving the asset units. Null for
|
187
|
-
# retirements.
|
188
|
-
# @return [String]
|
189
|
-
attrib :destination_account_alias
|
190
|
-
|
191
|
-
# @!attribute [r] destination_account_tags
|
192
|
-
# Deprecated. Use {#snapshot} instead.
|
193
|
-
# The tags of the account receiving the flavor units.
|
194
|
-
# Null for retirements.
|
195
|
-
# @return [String]
|
196
|
-
attrib :destination_account_tags
|
197
|
-
|
198
|
-
# @!attribute [r] tags
|
199
|
-
# User-specified, key-value data embedded into the action.
|
200
|
-
# @return [Hash]
|
201
|
-
attrib :tags
|
202
|
-
|
203
|
-
# @!attribute [r] reference_data
|
204
|
-
# Deprecated. Use {#tags} instead.
|
205
|
-
# User-specified, key-value data embedded into the action.
|
206
|
-
# @return [Hash]
|
207
|
-
attrib :reference_data
|
208
|
-
end
|
209
|
-
|
210
112
|
# A configuration object for creating and submitting transactions.
|
211
113
|
class Builder
|
212
114
|
include Sequence::Validations
|
213
115
|
|
116
|
+
# @deprecated Use {Sequence::Action#tags} instead.
|
214
117
|
attr_accessor :reference_data
|
215
118
|
|
216
119
|
def initialize(&block)
|
data/lib/sequence/validations.rb
CHANGED
data/lib/sequence/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequence-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chain Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: SDK for Sequence
|
14
14
|
email:
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/sequence/contract.rb
|
29
29
|
- lib/sequence/dev_utils.rb
|
30
30
|
- lib/sequence/errors.rb
|
31
|
+
- lib/sequence/feed.rb
|
31
32
|
- lib/sequence/flavor.rb
|
32
33
|
- lib/sequence/http_wrapper.rb
|
33
34
|
- lib/sequence/key.rb
|
@@ -60,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
61
|
version: '0'
|
61
62
|
requirements: []
|
62
63
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.6
|
64
|
+
rubygems_version: 2.7.6
|
64
65
|
signing_key:
|
65
66
|
specification_version: 4
|
66
67
|
summary: SDK for Sequence
|