sequence-sdk 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28c08904ccde3f52784afaafd26a1b29bd355766
4
- data.tar.gz: f2d920c03bcace1947a502e6318a017c01343e88
3
+ metadata.gz: 94c78d487e125ca4d9436ba7651feeaa4df4e42c
4
+ data.tar.gz: 4686db08afa33c144752c475e682e133b3e7dad7
5
5
  SHA512:
6
- metadata.gz: f0d1206153259d71dd09f2650c1c23c707fb4030994f8b1e0cabd30f0eff9c93900f1ff19677c1759e1d611c8c0490638d1c6ed7a1837f8a325ac27d688d0d74
7
- data.tar.gz: c7dfa259a099af2aaff4d52ec10203a24ea6bc35cd552210b416c2f2f0a41900371c665982c39c7ea11cee457d702b5aba6f4de5808f85a8a3ffe6c5d611c033
6
+ metadata.gz: 3b8efcc73ad670aa4df6b2adadc9e6be07043b77e06b0098f918e332dd3df4563e870f31ea561a4bde52e2720d5c3a8904a20cb8db36c30743713dd1caf0c8b6
7
+ data.tar.gz: 46da2a5e7ab4800d88c47dc98725da383fa56c54eb8b64a08ed232a50fb750b87277904d90d48a9163c88a34a7ba70a2d80d71389ff7df9d35276ac653e5084b
data/lib/sequence.rb CHANGED
@@ -1,3 +1,2 @@
1
1
  require_relative './sequence/client'
2
- require_relative './sequence/constants'
3
2
  require_relative './sequence/version'
@@ -4,30 +4,31 @@ require_relative './query'
4
4
  require_relative './response_object'
5
5
 
6
6
  module Sequence
7
+ # A container for asset balances on a ledger.
7
8
  class Account < ResponseObject
8
9
 
9
10
  # @!attribute [r] id
10
- # Unique account identifier.
11
+ # Unique, auto-generated identifier.
11
12
  # @return [String]
12
13
  attrib :id
13
14
 
14
15
  # @!attribute [r] alias
15
- # User specified, unique identifier.
16
+ # Unique, user-specified identifier.
16
17
  # @return [String]
17
18
  attrib :alias
18
19
 
19
- # @!attribute [r] quorum
20
- # The number of keys required to sign transactions for the account.
21
- # @return [Integer]
22
- attrib :quorum
23
-
24
20
  # @!attribute [r] keys
25
- # The set of keys used for signing issuance transactions for this asset.
21
+ # The set of keys used for signing transactions that spend from the account.
26
22
  # @return [Array<Key>]
27
23
  attrib(:keys) { |raw| raw.map { |k| Key.new(k) } }
28
24
 
25
+ # @!attribute [r] quorum
26
+ # The number of keys required to sign transactions that spend from the account.
27
+ # @return [Integer]
28
+ attrib :quorum
29
+
29
30
  # @!attribute [r] tags
30
- # User-specified tag structure for the account.
31
+ # User-specified key-value data describing the account.
31
32
  # @return [Hash]
32
33
  attrib :tags
33
34
 
@@ -37,29 +38,32 @@ module Sequence
37
38
  end
38
39
 
39
40
  class ClientModule < Sequence::ClientModule
40
- # @param [Hash] opts Options hash specifiying account creation details.
41
- # @option opts [String] alias User specified, unique identifier.
42
- # @option opts [Array<Hash>] keys The list of keys used to create control programs under the account. A key is a hash containing either an `id` or `alias` key.
43
- # @option opts [Integer] quorum The number of keys required to sign transactions for the account. Defaults to the size of root_xpubs.
44
- # @option opts [Hash] tags User-specified tag structure for the account.
41
+ # Creates a new account in the ledger.
42
+ # @param [Hash] opts Options hash
43
+ # @option opts [String] alias Unique, user-specified identifier.
44
+ # @option opts [Array<Hash>, Array<Sequence::Key>] keys The set of keys used for signing transactions that spend from the account. A key can be either a key object, or a hash containing either an `id` or `alias` field.
45
+ # @option opts [Integer] quorum The number of keys required to sign transactions that spend from the account. Defaults to the number of keys provided.
46
+ # @option opts [Hash] tags User-specified key-value data describing the account.
45
47
  # @return [Account]
46
48
  def create(opts)
47
49
  opts = {client_token: SecureRandom.uuid}.merge(opts)
48
50
  Account.new(client.conn.request('create-account', opts))
49
51
  end
50
52
 
51
- # @param [Hash] opts Options hash specifiying account creation details.
53
+ # Updates an account's tags.
54
+ # @param [Hash] opts Options hash
52
55
  # @option opts [String] id The ID of the account. Either an ID or alias should be provided, but not both.
53
56
  # @option opts [String] alias The alias of the account. Either an ID or alias should be provided, but not both.
54
57
  # @option opts [Hash] tags A new set of tags, which will replace the existing tags.
55
- # @return [Hash] a success message.
58
+ # @return [void]
56
59
  def update_tags(opts)
57
60
  client.conn.request('update-account-tags', opts)
58
61
  end
59
62
 
60
- # @param [Hash] opts Filtering information
61
- # @option opts [String] filter Filter string, see {https://chain.com/docs/core/build-applications/queries}.
62
- # @option opts [Array<String|Integer>] filter_params Parameter values for filter string (if needed).
63
+ # Executes a query, returning an enumerable over individual accounts.
64
+ # @param [Hash] opts Options hash
65
+ # @option opts [String] filter A filter expression.
66
+ # @option opts [Array<String|Integer>] filter_params A list of values that will be interpolated into the filter expression.
63
67
  # @return [Query]
64
68
  def query(opts = {})
65
69
  Query.new(client, opts)
@@ -6,33 +6,31 @@ require_relative './query'
6
6
  require_relative './response_object'
7
7
 
8
8
  module Sequence
9
+ # A type or class of value that can be tracked on a ledger.
9
10
  class Asset < ResponseObject
10
11
 
11
12
  # @!attribute [r] id
12
- # Globally unique identifier of the asset.
13
- # Asset version 1 specifies the asset id as the hash of:
14
- # - the asset version
15
- # - the asset's issuance program
16
- # - the core's VM version
17
- # - the hash of the network's initial block
13
+ # Unique, auto-generated identifier.
18
14
  # @return [String]
19
15
  attrib :id
20
16
 
21
17
  # @!attribute [r] alias
22
- # User specified, unique identifier.
18
+ # Unique, user-specified identifier.
23
19
  # @return [String]
24
20
  attrib :alias
25
21
 
26
22
  # @!attribute [r] keys
27
- # The set of keys used for signing issuance transactions for this asset.
23
+ # The set of keys used to sign transactions that issue the asset.
28
24
  # @return [Array<Key>]
29
25
  attrib(:keys) { |raw| raw.map { |k| Key.new(k) } }
30
26
 
31
27
  # @!attribute [r] quorum
28
+ # The number of keys required to sign transactions that issue the asset.
32
29
  # @return [Integer]
33
30
  attrib :quorum
34
31
 
35
32
  # @!attribute [r] tags
33
+ # User-specified key-value data describing the asset.
36
34
  # @return [Hash]
37
35
  attrib :tags
38
36
 
@@ -42,29 +40,32 @@ module Sequence
42
40
  end
43
41
 
44
42
  class ClientModule < Sequence::ClientModule
45
- # @param [Hash] opts Options hash specifiying asset creation details.
46
- # @option opts [String] alias User specified, unique identifier.
47
- # @option opts [Array<Hash>] keys The list of keys used to create the issuance program for the asset. A key is a hash containing either an `id` or `alias` key.
48
- # @option opts [Integer] quorum The number of keys required to issue units of the asset. Defaults to the size of root_xpubs.
49
- # @option opts [Hash] tags User-specified, arbitrary/unstructured data local to the asset's originating core.
43
+ # Creates a new asset in the ledger.
44
+ # @param [Hash] opts Options hash
45
+ # @option opts [String] alias Unique, user-specified identifier.
46
+ # @option opts [Array<Hash>, Array<Sequence::Key>] keys The set of keys used for signing transactions that issue the asset. A key can be either a key object, or a hash containing either an `id` or `alias` field.
47
+ # @option opts [Integer] quorum The number of keys required to sign transactions that issue the asset. Defaults to the number of keys provided.
48
+ # @option opts [Hash] tags User-specified key-value data describing the asset.
50
49
  # @return [Asset]
51
50
  def create(opts)
52
51
  opts = {client_token: SecureRandom.uuid}.merge(opts)
53
52
  Asset.new(client.conn.request('create-asset', opts))
54
53
  end
55
54
 
56
- # @param [Hash] opts Options hash specifiying asset creation details.
55
+ # Updates an asset's tags.
56
+ # @param [Hash] opts Options hash
57
57
  # @option opts [String] id The ID of the asset. Either an ID or alias should be provided, but not both.
58
58
  # @option opts [String] alias The alias of the asset. Either an ID or alias should be provided, but not both.
59
59
  # @option opts [Hash] tags A new set of tags, which will replace the existing tags.
60
- # @return [Hash] a success message.
60
+ # @return [void]
61
61
  def update_tags(opts)
62
62
  client.conn.request('update-asset-tags', opts)
63
63
  end
64
64
 
65
- # @param [Hash] opts Filtering information
66
- # @option opts [String] filter Filter string, see {https://chain.com/docs/core/build-applications/queries}.
67
- # @option opts [Array<String|Integer>] filter_params Parameter values for filter string (if needed).
65
+ # Executes a query, returning an enumerable over individual assets.
66
+ # @param [Hash] opts Options hash
67
+ # @option opts [String] filter A filter expression.
68
+ # @option opts [Array<String|Integer>] filter_params A list of values that will be interpolated into the filter expression.
68
69
  # @return [Query]
69
70
  def query(opts = {})
70
71
  Query.new(client, opts)
@@ -2,25 +2,30 @@ require_relative './client_module'
2
2
  require_relative './response_object'
3
3
  require_relative './query'
4
4
 
5
+
5
6
  module Sequence
7
+ # A summation of contract amounts. Contracts are selected using a filter, and
8
+ # their values are summed using the common values of one or more contract
9
+ # fields.
6
10
  class Balance < ResponseObject
7
11
 
8
12
  # @!attribute [r] amount
9
- # Sum of the contracts.
13
+ # Summation of contract amounts.
10
14
  # @return [Integer]
11
15
  attrib :amount
12
16
 
13
17
  # @!attribute [r] sum_by
14
- # List of parameters on which to sum contracts.
18
+ # List of parameters along which contract amounts were summed.
15
19
  # @return [Hash<String => String>]
16
20
  attrib :sum_by
17
21
 
18
22
  class ClientModule < Sequence::ClientModule
19
- # @param [Hash] opts Filtering information
20
- # @option opts [String] filter Filter string, see {https://chain.com/docs/core/build-applications/queries}.
21
- # @option opts [Array<String|Integer>] filter_params Parameter values for filter string (if needed).
22
- # @option opts [Array<String>] sum_by List of contract attributes to sum by.
23
- # @option opts [Integer] timestamp A millisecond Unix timestamp. By using this parameter, you can perform queries that reflect the state of the blockchain at different points in time.
23
+ # Executes a query, returning an enumerable over individual balances.
24
+ # @param [Hash] opts Options hash
25
+ # @option opts [String] filter A filter expression.
26
+ # @option opts [Array<String|Integer>] filter_params A list of values that will be interpolated into the filter expression.
27
+ # @option opts [Array<String>] sum_by A list of fields along which contract values will be summed.
28
+ # @option opts [Integer] timestamp A millisecond Unix timestamp. Indicates that the query should be run over the state of the ledger at a given point in time.
24
29
  # @return [Query]
25
30
  def query(opts = {})
26
31
  Query.new(client, opts)
@@ -1,7 +1,6 @@
1
1
  require_relative './account'
2
2
  require_relative './asset'
3
3
  require_relative './balance'
4
- require_relative './constants'
5
4
  require_relative './contract'
6
5
  require_relative './dev_utils'
7
6
  require_relative './key'
@@ -11,6 +10,10 @@ require_relative './transaction'
11
10
  module Sequence
12
11
  class Client
13
12
 
13
+ # @param [Hash] opts Options hash
14
+ # @option opts [String] url The ledger API URL.
15
+ # @option opts [String] access_token The ledger access token.
16
+ # @return [Query]
14
17
  def initialize(opts = {})
15
18
  if !opts.key?(:url) || opts[:url].empty?
16
19
  raise ArgumentError.new('missing :url parameter')
@@ -1,4 +1,6 @@
1
1
  module Sequence
2
+ # Base class for ledger client components.
3
+ # @abstract
2
4
  class ClientModule
3
5
 
4
6
  attr_reader :client
@@ -3,56 +3,69 @@ require_relative './response_object'
3
3
  require_relative './query'
4
4
 
5
5
  module Sequence
6
+ # An entry in the ledger that contains value that can be spent.
6
7
  class Contract < ResponseObject
7
8
  # @!attribute [r] id
9
+ # A unique ID.
8
10
  # @return [String]
9
11
  attrib :id
10
12
 
11
13
  # @!attribute [r] type
14
+ # The type of the contract. Currently, this is always "account".
12
15
  # @return [String]
13
16
  attrib :type
14
17
 
15
18
  # @!attribute [r] transaction_id
19
+ # The ID of the transaction in which the contract appears.
16
20
  # @return [String]
17
21
  attrib :transaction_id
18
22
 
19
23
  # @!attribute [r] asset_id
24
+ # The ID of the asset held by the contract.
20
25
  # @return [String]
21
26
  attrib :asset_id
22
27
 
23
28
  # @!attribute [r] asset_alias
29
+ # The alias of the asset held by the contract.
24
30
  # @return [String]
25
31
  attrib :asset_alias
26
32
 
27
33
  # @!attribute [r] asset_tags
34
+ # The tags of the asset held by the contract.
28
35
  # @return [Hash]
29
36
  attrib :asset_tags
30
37
 
31
38
  # @!attribute [r] amount
39
+ # The number of units of the asset held by the contract.
32
40
  # @return [Integer]
33
41
  attrib :amount
34
42
 
35
43
  # @!attribute [r] account_id
44
+ # The ID of the account controlling the contract.
36
45
  # @return [String]
37
46
  attrib :account_id
38
47
 
39
48
  # @!attribute [r] account_alias
49
+ # The alias of the account controlling the contract.
40
50
  # @return [String]
41
51
  attrib :account_alias
42
52
 
43
53
  # @!attribute [r] account_tags
54
+ # The tags of the account controlling the contract.
44
55
  # @return [Hash]
45
56
  attrib :account_tags
46
57
 
47
58
  # @!attribute [r] reference_data
59
+ # User-specified key-value data embedded in the contract.
48
60
  # @return [Hash]
49
61
  attrib :reference_data
50
62
 
51
63
  class ClientModule < Sequence::ClientModule
52
- # @param [Hash] opts Filtering information
53
- # @option opts [String] filter Filter string, see {https://chain.com/docs/core/build-applications/queries}.
54
- # @option opts [Array<String|Integer>] filter_params Parameter values for filter string (if needed).
55
- # @option opts [Integer] timestamp A millisecond Unix timestamp. By using this parameter, you can perform queries that reflect the state of the blockchain at different points in time.
64
+ # Executes a query, returning an enumerable over individual contracts.
65
+ # @param [Hash] opts Options hash
66
+ # @option opts [String] filter A filter expression.
67
+ # @option opts [Array<String|Integer>] filter_params A list of values that will be interpolated into the filter expression.
68
+ # @option opts [Integer] timestamp A millisecond Unix timestamp. Indicates that the query should be run over the state of the ledger at a given point in time.
56
69
  # @return [Query]
57
70
  def query(opts = {})
58
71
  Query.new(client, opts)
@@ -4,8 +4,9 @@ require_relative './client_module'
4
4
 
5
5
  module Sequence
6
6
  class DevUtils
7
+ # A namespace for development-only methods.
7
8
  class ClientModule < Sequence::ClientModule
8
- # Deletes all data in the ledger. (development ledgers only)
9
+ # Deletes all data in the ledger.
9
10
  def reset
10
11
  client.conn.request('/reset', client_token: SecureRandom.uuid)
11
12
  end
@@ -1,23 +1,23 @@
1
1
  module Sequence
2
2
 
3
- # Base class for all errors raised by the Chain SDK.
3
+ # Base class for all errors raised by the Sequence SDK.
4
4
  class BaseError < StandardError; end
5
5
 
6
6
  # InvalidRequestIDError arises when an HTTP response is received, but it does
7
- # not contain headers that are included in all Chain API responses. This
7
+ # not contain headers that are included in all Sequence API responses. This
8
8
  # could arise due to a badly-configured proxy, or other upstream network
9
9
  # issues.
10
10
  class InvalidRequestIDError < BaseError
11
11
  attr_accessor :response
12
12
 
13
13
  def initialize(response)
14
- super "Response HTTP header field Chain-Request-ID is unset. There may be network issues. Please check your local network settings."
14
+ super "Response HTTP header field Sequence-Request-ID is unset. There may be network issues. Please check your local network settings."
15
15
  self.response = response
16
16
  end
17
17
  end
18
18
 
19
19
  # JSONError should be very rare, and will only arise if there is a bug in the
20
- # Chain API, or if the upstream server is spoofing common Chain API response
20
+ # Sequence API, or if the upstream server is spoofing common Sequence API response
21
21
  # headers.
22
22
  class JSONError < BaseError
23
23
  attr_accessor :request_id
@@ -30,7 +30,7 @@ module Sequence
30
30
  end
31
31
  end
32
32
 
33
- # APIError describes errors that are codified by the Chain API. They have
33
+ # APIError describes errors that are codified by the Sequence API. They have
34
34
  # an error code, a message, and an optional detail field that provides
35
35
  # additional context for the error.
36
36
  class APIError < BaseError
@@ -53,7 +53,7 @@ module Sequence
53
53
  self.temporary = body['temporary']
54
54
 
55
55
  self.response = response
56
- self.request_id = response['Chain-Request-ID'] if response
56
+ self.request_id = response['Sequence-Request-ID'] if response
57
57
 
58
58
  super self.class.format_error_message(code, chain_message, detail, request_id)
59
59
  end
data/lib/sequence/key.rb CHANGED
@@ -4,29 +4,31 @@ require_relative './query'
4
4
  require_relative './response_object'
5
5
 
6
6
  module Sequence
7
+ # Keys are used to sign transactions.
7
8
  class Key < ResponseObject
8
- # @!attribute [r] alias
9
- # User specified, unique identifier of the key.
10
- # @return [String]
11
- attrib :alias
12
-
13
9
  # @!attribute [r] id
14
10
  # Unique identifier of the key, based on the public key material itself.
15
11
  # @return [String]
16
12
  attrib :id
17
13
 
14
+ # @!attribute [r] alias
15
+ # Unique, user-specified identifier of the key.
16
+ # @return [String]
17
+ attrib :alias
18
+
18
19
  class ClientModule < Sequence::ClientModule
19
20
 
20
- # Creates a key object.
21
- # @param [Hash] opts Parameters for MockHSM key creation.
22
- # @option opts [String] alias User specified, unique identifier.
21
+ # Creates a key.
22
+ # @param [Hash] opts Options hash
23
+ # @option opts [String] alias Unique, user-specified identifier of the key.
23
24
  # @return [Key]
24
25
  def create(opts = {})
25
26
  Key.new(client.conn.request('create-key', opts))
26
27
  end
27
28
 
28
- # @param [Hash] opts Filtering information
29
- # @option opts [Array<String>] aliases Optional list of requested aliases, max 200.
29
+ # Executes a query, returning an enumerable over individual keys.
30
+ # @param [Hash] opts Options hash
31
+ # @option opts [Array<String>] aliases A list of aliases of keys to retrieve.
30
32
  # @return [Query]
31
33
  def query(opts = {})
32
34
  Query.new(client, opts)
@@ -3,24 +3,26 @@ require_relative './response_object'
3
3
  require_relative './query'
4
4
 
5
5
  module Sequence
6
+ # An object describing summary information about a ledger.
6
7
  class Stats < ResponseObject
7
8
 
8
9
  # @!attribute [r] asset_count
9
- # Total number of assets in the ledger.
10
+ # The number of assets in the ledger.
10
11
  # @return [Integer]
11
12
  attrib :asset_count
12
13
 
13
14
  # @!attribute [r] account_count
14
- # Total number of accounts in the ledger.
15
+ # The number of accounts in the ledger.
15
16
  # @return [Integer]
16
17
  attrib :account_count
17
18
 
18
19
  # @!attribute [r] tx_count
19
- # Total number of transactions in the ledger.
20
+ # The number of transactions in the ledger.
20
21
  # @return [Integer]
21
22
  attrib :tx_count
22
23
 
23
24
  class ClientModule < Sequence::ClientModule
25
+ # Gets stats from the ledger.
24
26
  # @return [Stats]
25
27
  def get
26
28
  Stats.new(client.conn.request('stats'))
@@ -5,10 +5,13 @@ require_relative './query'
5
5
  require_relative './response_object'
6
6
 
7
7
  module Sequence
8
+ # A transaction is an atomic update to the state of the ledger. Transactions
9
+ # can issue new asset units, transfer of asset units from one account to
10
+ # another, and/or the retire asset units from an account.
8
11
  class Transaction < ResponseObject
9
12
 
10
13
  # @!attribute [r] id
11
- # Unique transaction identifier.
14
+ # A unique ID.
12
15
  # @return [String]
13
16
  attrib :id
14
17
 
@@ -23,17 +26,17 @@ module Sequence
23
26
  attrib :sequence_number
24
27
 
25
28
  # @!attribute [r] reference_data
26
- # User specified, unstructured data embedded within a transaction.
29
+ # User-specified key-value data embedded into the transaction.
27
30
  # @return [Hash]
28
31
  attrib :reference_data
29
32
 
30
33
  # @!attribute [r] actions
31
- # List of a transaction's actions.
34
+ # List of actions taken by the transaction.
32
35
  # @return [Array<Action>]
33
36
  attrib(:actions) { |raw| raw.map { |v| Action.new(v) } }
34
37
 
35
38
  # @!attribute [r] contracts
36
- # List of a transaction's contracts.
39
+ # List of contracts created by the transaction.
37
40
  # @return [Array<Contract>]
38
41
  attrib(:contracts) { |raw| raw.map { |v| Contract.new(v) } }
39
42
 
@@ -58,13 +61,12 @@ module Sequence
58
61
  ))
59
62
  end
60
63
 
61
- # List all transactions, optionally filtered
62
- # @param [Hash] opts Filtering information
63
- # @option opts [String] filter Filter string, see {https://chain.com/docs/core/build-applications/queries}.
64
- # @option opts [Array<String|Integer>] filter_params Parameter values for filter string (if needed).
65
- # @option opts [Integer] start_time A Unix timestamp in milliseconds. When specified, only transactions with a block time greater than the start time will be returned.
66
- # @option opts [Integer] end_time A Unix timestamp in milliseconds. When specified, only transactions with a block time less than the start time will be returned.
67
- # @option opts [Integer] timeout A time in milliseconds after which a server timeout should occur. Defaults to 1000 (1 second).
64
+ # Executes a query, returning an enumerable over individual transactions.
65
+ # @param [Hash] opts Options hash
66
+ # @option opts [String] filter A filter expression.
67
+ # @option opts [Array<String|Integer>] filter_params A list of values that will be interpolated into the filter expression.
68
+ # @option opts [Integer] start_time A Unix timestamp in milliseconds of the earliest transaction timestamp to include in the query results.
69
+ # @option opts [Integer] end_time A Unix timestamp in milliseconds of the most recent transaction timestamp to include in the query results.
68
70
  # @return [Query]
69
71
  def query(opts = {})
70
72
  Query.new(client, opts)
@@ -81,11 +83,10 @@ module Sequence
81
83
  end
82
84
  end
83
85
 
86
+ # An action taken by a transaction.
84
87
  class Action < ResponseObject
85
88
  # @!attribute [r] type
86
- # The type of the action.
87
- #
88
- # Possible values are "issue", "transfer" and "retire".
89
+ # The type of the action. Possible values are "issue", "transfer" and "retire".
89
90
  # @return [String]
90
91
  attrib :type
91
92
 
@@ -95,61 +96,57 @@ module Sequence
95
96
  attrib :asset_id
96
97
 
97
98
  # @!attribute [r] asset_alias
98
- # The alias of the action's asset (possibly null).
99
+ # The alias of the action's asset.
99
100
  # @return [String]
100
101
  attrib :asset_alias
101
102
 
102
103
  # @!attribute [r] asset_tags
103
- # The tags of the action's asset (possibly null).
104
+ # The tags of the action's asset.
104
105
  # @return [Hash]
105
106
  attrib :asset_tags
106
107
 
107
108
  # @!attribute [r] amount
108
- # The number of units of the action's asset.
109
+ # The number of asset units issues, transferred, or retired.
109
110
  # @return [Integer]
110
111
  attrib :amount
111
112
 
112
113
  # @!attribute [r] source_account_id
113
- # The id of the account transferring the asset (possibly null if the
114
- # action is an issuance).
114
+ # The ID of the account serving as the source of asset units. Null for issuances.
115
115
  # @return [String]
116
116
  attrib :source_account_id
117
117
 
118
118
  # @!attribute [r] source_account_alias
119
- # The alias of the account transferring the asset (possibly null if the
120
- # action is an issuance).
119
+ # The alias of the account serving as the source of asset units. Null for issuances.
121
120
  # @return [String]
122
121
  attrib :source_account_alias
123
122
 
124
123
  # @!attribute [r] source_account_tags
125
- # The tags associated with the source account (possibly null).
124
+ # The tags of the account serving as the source of asset units. Null for issuances.
126
125
  # @return [String]
127
126
  attrib :source_account_tags
128
127
 
129
128
  # @!attribute [r] destination_account_id
130
- # The id of the account receiving the asset (possibly null if the
131
- # action is a retirement).
129
+ # The ID of the account receiving the asset units. Null for retirements.
132
130
  # @return [String]
133
131
  attrib :destination_account_id
134
132
 
135
133
  # @!attribute [r] destination_account_alias
136
- # The alias of the account receiving the asset (possibly null if the
137
- # action is an retirement).
134
+ # The alias of the account receiving the asset units. Null for retirements.
138
135
  # @return [String]
139
136
  attrib :destination_account_alias
140
137
 
141
138
  # @!attribute [r] destination_account_tags
142
- # The tags associated with the destination account (possibly null).
139
+ # The tags of the account receiving the asset units. Null for retirements.
143
140
  # @return [String]
144
141
  attrib :destination_account_tags
145
142
 
146
143
  # @!attribute [r] reference_data
147
- # User specified, unstructured data embedded within an action
148
- # (possibly null).
144
+ # User-specified, key-value data embedded into the action.
149
145
  # @return [Hash]
150
146
  attrib :reference_data
151
147
  end
152
148
 
149
+ # A configuration object for creating and submitting transactions.
153
150
  class Builder
154
151
  attr_accessor :reference_data
155
152
 
@@ -157,12 +154,10 @@ module Sequence
157
154
  block.call(self) if block
158
155
  end
159
156
 
160
- # @return [Array<Hash>]
161
157
  def actions
162
158
  @actions ||= []
163
159
  end
164
160
 
165
- # @return [Hash]
166
161
  def to_h
167
162
  {
168
163
  actions: actions,
@@ -170,14 +165,12 @@ module Sequence
170
165
  }
171
166
  end
172
167
 
173
- # @return [String]
174
168
  def to_json(opts = nil)
175
169
  to_h.to_json(opts)
176
170
  end
177
171
 
178
- # Add an action to the transaction builder
179
- # @param [Hash] params Action parameters containing a type field and the
180
- # required parameters for that type
172
+ # Adds an action to a transaction builder.
173
+ # @param [Hash] params Action parameters.
181
174
  # @return [Builder]
182
175
  def add_action(params)
183
176
  # Some actions require an idempotency token, so we'll add it here as a
@@ -187,66 +180,68 @@ module Sequence
187
180
  self
188
181
  end
189
182
 
190
- # Issue new units of an asset into an account.
191
- # @param [Hash] params Action parameters
192
- # @option params [String] :asset_id Asset ID specifying the asset to be issued.
193
- # You must specify either an ID or an alias.
194
- # @option params [String] :asset_alias Asset alias specifying the asset to be issued.
195
- # You must specify either an ID or an alias.
196
- # @option params [Integer] :amount amount of the asset to be issued
197
- # @option params [String] :destination_account_id ID of account receiving the newly-issued asset units.
183
+ # Issues new units of an asset to a destination account.
184
+ #
185
+ # @param [Hash] params Options hash
186
+ # @option params [String] :asset_id ID of the asset to be issued.
198
187
  # You must specify either an ID or an alias.
199
- # @option params [String] :destination_account_alias Alias of account receiving the newly-issued asset units.
188
+ # @option params [String] :asset_alias Asset alias of the asset to be issued.
200
189
  # You must specify either an ID or an alias.
201
- # @option params [Hash] :reference_data Reference data to add to the receiving contract.
190
+ # @option params [Integer] :amount amount of the asset to be issued.
191
+ # @option params [String] :destination_account_id ID of the account receiving the asset units.
192
+ # You must specify a destination account ID or alias.
193
+ # @option params [String] :destination_account_alias alias of the account receiving the asset units.
194
+ # You must specify a destination account ID or alias.
195
+ # @option params [Hash] :reference_data reference data for the action.
202
196
  # @return [Builder]
203
197
  def issue(params)
204
198
  add_action(params.merge(type: :issue))
205
199
  end
206
200
 
207
- # Takes units of an asset from a source (an account or contract) and retires them.
208
- # @param [Hash] params Action parameters
209
- # @option params [String] :source_account_id Account ID specifying the account controlling the asset.
201
+ # Moves units of an asset from a source (an account or contract) to a destination account.
202
+ #
203
+ # @param [Hash] params Options hash
204
+ # @option params [String] :source_account_id ID of the account serving as the source of asset units.
210
205
  # You must specify a source account ID, account alias, or contract ID.
211
- # @option params [String] :source_account_alias Account alias specifying the account controlling the asset.
206
+ # @option params [String] :source_account_alias Alias of the account serving as the source of asset units
212
207
  # You must specify a source account ID, account alias, or contract ID.
213
- # @option params [String] :source_contract_id Contract holding the asset.
208
+ # @option params [String] :source_contract_id ID of the contract serving as the source of asset units.
214
209
  # You must specify a source account ID, account alias, or contract ID.
215
- # @option params [String] :asset_id Asset ID specifying the asset to be retired.
210
+ # @option params [String] :asset_id ID of the asset to be transferred.
216
211
  # You must specify either an ID or an alias.
217
- # @option params [String] :asset_alias Asset alias specifying the asset to be retired.
212
+ # @option params [String] :asset_alias Asset alias of the asset to be transferred.
218
213
  # You must specify either an ID or an alias.
219
- # @option params [Integer] :amount Amount of the asset to be retired.
220
- # @option params [Hash] :reference_data Reference data to add to the receiving contract.
221
- # @option params [Hash] :change_reference_data Reference data to add to the change contract, if it is necessary.
214
+ # @option params [Integer] :amount amount of the asset to be transferred.
215
+ # @option params [String] :destination_account_id ID of the account receiving the asset units.
216
+ # You must specify a destination account ID or alias.
217
+ # @option params [String] :destination_account_alias alias of the account receiving the asset units.
218
+ # You must specify a destination account ID or alias.
219
+ # @option params [Hash] :reference_data reference data for the action.
220
+ # @option params [Hash] :change_reference_data reference data for the change contract.
222
221
  # @return [Builder]
223
- def retire(params)
224
- add_action(params.merge(type: :retire))
222
+ def transfer(params)
223
+ add_action(params.merge(type: :transfer))
225
224
  end
226
225
 
227
- # Moves units of an asset from a source (an account or contract) to a destination account.
226
+ # Takes units of an asset from a source (an account or contract) and retires them.
228
227
  #
229
- # @param [Hash] params Action parameters
230
- # @option params [String] :source_account_id Account ID specifying the account controlling the asset.
228
+ # @param [Hash] params Options hash
229
+ # @option params [String] :source_account_id ID of the account serving as the source of asset units.
231
230
  # You must specify a source account ID, account alias, or contract ID.
232
- # @option params [String] :source_account_alias Account alias specifying the account controlling the asset.
231
+ # @option params [String] :source_account_alias Alias of the account serving as the source of asset units
233
232
  # You must specify a source account ID, account alias, or contract ID.
234
- # @option params [String] :source_contract_id Contract holding the asset.
233
+ # @option params [String] :source_contract_id ID of the contract serving as the source of asset units.
235
234
  # You must specify a source account ID, account alias, or contract ID.
236
- # @option params [String] :asset_id Asset ID specifying the asset to be transferred.
235
+ # @option params [String] :asset_id ID of the asset to be retired.
237
236
  # You must specify either an ID or an alias.
238
- # @option params [String] :asset_alias Asset alias specifying the asset to be transferred.
237
+ # @option params [String] :asset_alias Asset alias of the asset to be retired.
239
238
  # You must specify either an ID or an alias.
240
- # @option params [Integer] :amount Amount of the asset to be transferred.
241
- # @option params [String] :destination_account_id Account ID specifying the account controlling the asset.
242
- # You must specify a destination account ID or alias.
243
- # @option params [String] :destination_account_alias Account alias specifying the account controlling the asset.
244
- # You must specify a destination account ID or alias.
245
- # @option params [Hash] :reference_data Reference data to add to the receiving contract.
246
- # @option params [Hash] :change_reference_data Reference data to add to the change contract, if it is necessary.
239
+ # @option params [Integer] :amount amount of the asset to be retired.
240
+ # @option params [Hash] :reference_data reference data for the action.
241
+ # @option params [Hash] :change_reference_data reference data for the change contract.
247
242
  # @return [Builder]
248
- def transfer(params)
249
- add_action(params.merge(type: :transfer))
243
+ def retire(params)
244
+ add_action(params.merge(type: :retire))
250
245
  end
251
246
  end
252
247
  end
@@ -1,3 +1,3 @@
1
1
  module Sequence
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,137 +1,137 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequence-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chain Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-21 00:00:00.000000000 Z
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler-audit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 3.5.0
62
- - - ">="
62
+ - - '>='
63
63
  - !ruby/object:Gem::Version
64
64
  version: 3.5.0
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - "~>"
69
+ - - ~>
70
70
  - !ruby/object:Gem::Version
71
71
  version: 3.5.0
72
- - - ">="
72
+ - - '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: 3.5.0
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec-its
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ~>
80
80
  - !ruby/object:Gem::Version
81
81
  version: 1.2.0
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ~>
87
87
  - !ruby/object:Gem::Version
88
88
  version: 1.2.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: simplecov
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ~>
94
94
  - !ruby/object:Gem::Version
95
95
  version: 0.14.1
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ~>
101
101
  - !ruby/object:Gem::Version
102
102
  version: 0.14.1
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: webmock
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - "~>"
107
+ - - ~>
108
108
  - !ruby/object:Gem::Version
109
109
  version: 2.3.2
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - "~>"
114
+ - - ~>
115
115
  - !ruby/object:Gem::Version
116
116
  version: 2.3.2
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: yard
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - "~>"
121
+ - - ~>
122
122
  - !ruby/object:Gem::Version
123
123
  version: 0.9.5
124
- - - ">="
124
+ - - '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: 0.9.5
127
127
  type: :development
128
128
  prerelease: false
129
129
  version_requirements: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - "~>"
131
+ - - ~>
132
132
  - !ruby/object:Gem::Version
133
133
  version: 0.9.5
134
- - - ">="
134
+ - - '>='
135
135
  - !ruby/object:Gem::Version
136
136
  version: 0.9.5
137
137
  description: SDK for Sequence
@@ -140,16 +140,14 @@ executables: []
140
140
  extensions: []
141
141
  extra_rdoc_files: []
142
142
  files:
143
- - LICENSE
144
143
  - README.md
145
- - lib/sequence.rb
144
+ - LICENSE
146
145
  - lib/sequence/account.rb
147
146
  - lib/sequence/asset.rb
148
147
  - lib/sequence/balance.rb
149
148
  - lib/sequence/client.rb
150
149
  - lib/sequence/client_module.rb
151
150
  - lib/sequence/connection.rb
152
- - lib/sequence/constants.rb
153
151
  - lib/sequence/contract.rb
154
152
  - lib/sequence/dev_utils.rb
155
153
  - lib/sequence/errors.rb
@@ -160,6 +158,7 @@ files:
160
158
  - lib/sequence/stats.rb
161
159
  - lib/sequence/transaction.rb
162
160
  - lib/sequence/version.rb
161
+ - lib/sequence.rb
163
162
  homepage: https://dashboard.sequenceledger.com
164
163
  licenses:
165
164
  - Apache-2.0
@@ -170,17 +169,17 @@ require_paths:
170
169
  - lib
171
170
  required_ruby_version: !ruby/object:Gem::Requirement
172
171
  requirements:
173
- - - "~>"
172
+ - - ~>
174
173
  - !ruby/object:Gem::Version
175
174
  version: '2.0'
176
175
  required_rubygems_version: !ruby/object:Gem::Requirement
177
176
  requirements:
178
- - - ">="
177
+ - - '>='
179
178
  - !ruby/object:Gem::Version
180
179
  version: '0'
181
180
  requirements: []
182
181
  rubyforge_project:
183
- rubygems_version: 2.6.8
182
+ rubygems_version: 2.0.14.1
184
183
  signing_key:
185
184
  specification_version: 4
186
185
  summary: SDK for Sequence
@@ -1,3 +0,0 @@
1
- module Sequence
2
- MAX_BLOCK_HEIGHT = (2 ** 63) - 1
3
- end