sequence-sdk 1.0.4 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da13e33f0caa12bd428d4a97a545e42603369f68
4
- data.tar.gz: b660490b8b64779fa01eb22ddfbb94a609946955
3
+ metadata.gz: d3f404ef05907abe4fc55a63fb30df360c3f7737
4
+ data.tar.gz: f0413842e1753dd1900cc1a21817a545536fcc36
5
5
  SHA512:
6
- metadata.gz: 184219f173c60a722b8f8356801f24897c17dc420c114fbf7609285135ae7dbc211bbc1a23fa185d5a97bb97436e401fdd74751f2eca88eff1e910e14117bab2
7
- data.tar.gz: c7309542abbea40fbbd42a29072a1751b61693f06dd133ea4778ff85638fcc62b177916ded02a84b46c936d0b4c7d197a5ed151dc1ddb2da16dec3372d6599ab
6
+ metadata.gz: 709080c4bc1c622863c7c3cd1d657f0301df71c895fcd3bb98ac77d6838efdf281a0c8982ed4cfdb4893ef4e716d5030c6d8462b3146dfa36a39c1e7555ad1e6
7
+ data.tar.gz: 268eb83516a6ff005c7e031af68f18a99bae51d92797241d02805c8bbaea0429f28cfa491f0d7d74b1917e9dd180bdf6847fc2de02f67c16c9c21350e7edfc06
data/README.md CHANGED
@@ -13,17 +13,17 @@ for the language's schedule for security and bug fixes.
13
13
 
14
14
  Add the following to your `Gemfile`:
15
15
 
16
- ```
17
- gem 'sequence-sdk'
16
+ ```ruby
17
+ gem 'sequence-sdk', '~> 1.1.0'
18
18
  ```
19
19
 
20
20
  ### In your code
21
21
 
22
- ```
22
+ ```ruby
23
23
  require 'sequence'
24
24
 
25
25
  ledger = Sequence::Client.new(
26
- ledger: 'ledger',
26
+ ledger_name: 'ledger',
27
27
  credential: '...'
28
28
  )
29
29
  ```
@@ -12,6 +12,7 @@ module Sequence
12
12
  attrib :id
13
13
 
14
14
  # @!attribute [r] alias
15
+ # Deprecated. Use {#id} instead.
15
16
  # Unique, user-specified identifier.
16
17
  # @return [String]
17
18
  attrib :alias
@@ -42,7 +43,10 @@ module Sequence
42
43
  # Creates a new account in the ledger.
43
44
  # @param [Hash] opts
44
45
  # Options hash
46
+ # @option opts [String] id
47
+ # Unique, user-specified identifier.
45
48
  # @option opts [String] alias
49
+ # Deprecated. Use :id instead.
46
50
  # Unique, user-specified identifier.
47
51
  # @option opts [Array<Hash>, Array<Sequence::Key>] keys
48
52
  # The keys used for signing transactions that spend from the account. A
@@ -55,7 +59,7 @@ module Sequence
55
59
  # User-specified key-value data describing the account.
56
60
  # @return [Account]
57
61
  def create(opts = {})
58
- validate_inclusion_of!(opts, :alias, :keys, :quorum, :tags)
62
+ validate_inclusion_of!(opts, :alias, :id, :keys, :quorum, :tags)
59
63
  validate_required!(opts, :keys)
60
64
  Account.new(client.session.request('create-account', opts))
61
65
  end
@@ -67,6 +71,7 @@ module Sequence
67
71
  # The ID of the account. Either an ID or alias should be provided, but
68
72
  # not both.
69
73
  # @option opts [String] alias
74
+ # Deprecated. Use :id instead.
70
75
  # The alias of the account. Either an ID or alias should be provided,
71
76
  # but not both.
72
77
  # @option opts [Hash] tags
@@ -60,6 +60,7 @@ module Sequence
60
60
  attrib :source_account_id
61
61
 
62
62
  # @!attribute [r] source_account_alias
63
+ # Deprecated. Use {#source_account_id} instead
63
64
  # The alias of the source account executing the action.
64
65
  # @return [String]
65
66
  attrib :source_account_alias
@@ -75,6 +76,7 @@ module Sequence
75
76
  attrib :destination_account_id
76
77
 
77
78
  # @!attribute [r] destination_account_alias
79
+ # Deprecated. Use {#destination_account_id} instead
78
80
  # The alias of the destination account affected by the action.
79
81
  # @return [String]
80
82
  attrib :destination_account_alias
@@ -100,6 +102,14 @@ module Sequence
100
102
  # @option opts [Integer>] page_size
101
103
  # The number of items to return in the result set.
102
104
  # @return [Query]
105
+ # @example List all actions after a certain time
106
+ # ledger.actions.list(
107
+ # filter: 'timestamp > $1',
108
+ # filter_params: ['1985-10-26T01:21:00Z']
109
+ # ).each do |action|
110
+ # puts 'timestamp: ' + action.timestamp
111
+ # puts 'amount: ' + action.amount
112
+ # end
103
113
  def list(opts = {})
104
114
  validate_inclusion_of!(
105
115
  opts,
@@ -12,19 +12,25 @@ module Sequence
12
12
  class Client
13
13
  # @param [Hash] opts
14
14
  # Options hash
15
+ # @option opts [String] ledger_name
16
+ # Ledger name.
15
17
  # @option opts [String] ledger
18
+ # Deprecated. Use :ledger_name instead.
16
19
  # Ledger name.
17
20
  # @option opts [String] credential
18
21
  # API credential secret.
19
22
  # @return [Query]
20
23
  def initialize(opts = {})
21
- if opts[:ledger].nil? || opts[:ledger].empty?
22
- raise ArgumentError, ':ledger must be provided'
24
+ if (opts[:ledger_name].nil? || opts[:ledger_name].empty?) == (opts[:ledger].nil? || opts[:ledger].empty?)
25
+ raise ArgumentError, ':ledger_name or :ledger (but not both) must be provided'
23
26
  end
24
27
  if opts[:credential].nil? || opts[:credential].empty?
25
28
  raise ArgumentError, ':credential must be provided'
26
29
  end
27
30
 
31
+ if opts[:ledger_name].nil? || opts[:ledger_name].empty?
32
+ opts[:ledger_name] = opts[:ledger]
33
+ end
28
34
  @opts = opts
29
35
  end
30
36
 
@@ -46,6 +46,7 @@ module Sequence
46
46
  attrib :account_id
47
47
 
48
48
  # @!attribute [r] account_alias
49
+ # Deprecated. Use {#account_id} instead
49
50
  # The alias of the account controlling the contract.
50
51
  # @return [String]
51
52
  attrib :account_alias
@@ -1,7 +1,6 @@
1
1
  require 'net/http'
2
2
  require 'net/https'
3
3
  require 'openssl'
4
- require 'thread'
5
4
  require 'securerandom'
6
5
 
7
6
  module Sequence
@@ -59,6 +58,9 @@ module Sequence
59
58
  req['Macaroon'] = @macaroon
60
59
  req['Discharge-Macaroon'] = @dis_macaroon
61
60
  end
61
+ if !@opts[:user].nil? && !@opts[:pass].nil?
62
+ req.basic_auth(@opts[:user], @opts[:pass])
63
+ end
62
64
  unless @connection.started?
63
65
  @connection.start
64
66
  end
@@ -127,7 +129,7 @@ module Sequence
127
129
 
128
130
  # TLS configuration
129
131
  connection.use_ssl = true
130
- connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
132
+ connection.verify_mode = @opts[:verify_mode] || OpenSSL::SSL::VERIFY_PEER
131
133
  [:ca_file, :cert, :key].each do |k|
132
134
  next unless @opts.key?(:ssl_params) && @opts[:ssl_params].key?(k)
133
135
  connection.send("#{k}=", @opts[:ssl_params][k])
data/lib/sequence/key.rb CHANGED
@@ -12,6 +12,7 @@ module Sequence
12
12
  attrib :id
13
13
 
14
14
  # @!attribute [r] alias
15
+ # Deprecated. Use {#id} instead.
15
16
  # Unique, user-specified identifier of the key.
16
17
  # @return [String]
17
18
  attrib :alias
@@ -20,11 +21,14 @@ module Sequence
20
21
  # Creates a key.
21
22
  # @param [Hash] opts
22
23
  # Options hash
24
+ # @option opts [String] id
25
+ # Unique, user-specified identifier of the key.
23
26
  # @option opts [String] alias
27
+ # Deprecated. Use :id instead.
24
28
  # Unique, user-specified identifier of the key.
25
29
  # @return [Key]
26
30
  def create(opts = {})
27
- validate_inclusion_of!(opts, :alias)
31
+ validate_inclusion_of!(opts, :alias, :id)
28
32
  Key.new(client.session.request('create-key', opts))
29
33
  end
30
34
 
@@ -32,12 +36,15 @@ module Sequence
32
36
  # @param [Hash] opts
33
37
  # Options hash
34
38
  # @option opts [Array<String>] aliases
39
+ # Deprecated. Use :ids instead.
35
40
  # A list of aliases of keys to retrieve.
41
+ # @option opts [Array<String>] ids
42
+ # A list of ids of keys to retrieve.
36
43
  # @option opts [Integer>] page_size
37
44
  # The number of items to return in the result set.
38
45
  # @return [Query]
39
46
  def query(opts = {})
40
- validate_inclusion_of!(opts, :aliases, :page_size, :after)
47
+ validate_inclusion_of!(opts, :aliases, :ids, :page_size, :after)
41
48
  Query.new(client, opts)
42
49
  end
43
50
  end
@@ -11,8 +11,9 @@ module Sequence
11
11
  @opts = opts
12
12
  @host = @opts[:host] || 'https://api.seq.com'
13
13
  @session_host = @opts[:session_host] || 'https://session-api.seq.com'
14
- @ledger = @opts[:ledger] || raise(ArgumentError, "missing ledger")
14
+ @ledger = @opts[:ledger_name] || raise(ArgumentError, "missing ledger_name")
15
15
  @macaroon = @opts[:credential] || raise(ArgumentError, "missing credential")
16
+ @request_id = @opts[:request_id]
16
17
 
17
18
  # Start at 0 to trigger an immediate refresh
18
19
  @refresh_at = 0
@@ -42,7 +43,7 @@ module Sequence
42
43
  end
43
44
 
44
45
  def request(path, body = {})
45
- request_full_resp(nil, path, body)[:parsed_body]
46
+ request_full_resp(@request_id, path, body)[:parsed_body]
46
47
  end
47
48
 
48
49
  def request_full_resp(id, path, body = {})
@@ -128,6 +128,7 @@ module Sequence
128
128
  attrib :source_account_id
129
129
 
130
130
  # @!attribute [r] source_account_alias
131
+ # Deprecated. Use {#source_account_id} instead
131
132
  # The alias of the account serving as the source of asset units. Null
132
133
  # for issuances.
133
134
  # @return [String]
@@ -145,6 +146,7 @@ module Sequence
145
146
  attrib :destination_account_id
146
147
 
147
148
  # @!attribute [r] destination_account_alias
149
+ # Deprecated. Use {#destination_account_id} instead
148
150
  # The alias of the account receiving the asset units. Null for
149
151
  # retirements.
150
152
  # @return [String]
@@ -215,6 +217,7 @@ module Sequence
215
217
  # ID of the account receiving the asset units. You must specify a
216
218
  # destination account ID or alias.
217
219
  # @option opts [String] :destination_account_alias
220
+ # Deprecated. Use :destination_account_id instead
218
221
  # Alias of the account receiving the asset units. You must specify a
219
222
  # destination account ID or alias.
220
223
  # @option opts [Hash] :reference_data
@@ -256,6 +259,7 @@ module Sequence
256
259
  # ID of the account serving as the source of asset units. You must
257
260
  # specify a source account ID, account alias, or contract ID.
258
261
  # @option opts [String] :source_account_alias
262
+ # Deprecated. Use :source_account_id instead
259
263
  # Alias of the account serving as the source of asset units You must
260
264
  # specify a source account ID, account alias, or contract ID.
261
265
  # @option opts [String] :source_contract_id
@@ -265,6 +269,7 @@ module Sequence
265
269
  # ID of the account receiving the asset units. You must specify a
266
270
  # destination account ID or alias.
267
271
  # @option opts [String] :destination_account_alias
272
+ # Deprecated. Use :destination_account_id instead
268
273
  # Alias of the account receiving the asset units. You must specify a
269
274
  # destination account ID or alias.
270
275
  # @option opts [Hash] :reference_data
@@ -317,6 +322,7 @@ module Sequence
317
322
  # ID of the account serving as the source of asset units. You must
318
323
  # specify a source account ID, account alias, or contract ID.
319
324
  # @option opts [String] :source_account_alias
325
+ # Deprecated. Use :source_account_id instead
320
326
  # Alias of the account serving as the source of asset units You must
321
327
  # specify a source account ID, account alias, or contract ID.
322
328
  # @option opts [String] :source_contract_id
@@ -1,3 +1,3 @@
1
1
  module Sequence
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
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.0.4
4
+ version: 1.1.0
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-01-19 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -162,7 +162,7 @@ files:
162
162
  - lib/sequence/transaction.rb
163
163
  - lib/sequence/validations.rb
164
164
  - lib/sequence/version.rb
165
- homepage: https://dashboard.seq.com
165
+ homepage: https://github.com/sequence/sequence-sdk-ruby
166
166
  licenses:
167
167
  - Apache-2.0
168
168
  metadata: {}