coinbase-sdk 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +7 -4
  3. data/lib/coinbase/address.rb +36 -0
  4. data/lib/coinbase/client/api/addresses_api.rb +1 -1
  5. data/lib/coinbase/client/api/assets_api.rb +1 -1
  6. data/lib/coinbase/client/api/contract_events_api.rb +1 -1
  7. data/lib/coinbase/client/api/external_addresses_api.rb +86 -1
  8. data/lib/coinbase/client/api/networks_api.rb +85 -0
  9. data/lib/coinbase/client/api/server_signers_api.rb +1 -1
  10. data/lib/coinbase/client/api/stake_api.rb +121 -1
  11. data/lib/coinbase/client/api/trades_api.rb +1 -1
  12. data/lib/coinbase/client/api/transfers_api.rb +1 -1
  13. data/lib/coinbase/client/api/users_api.rb +1 -1
  14. data/lib/coinbase/client/api/validators_api.rb +1 -1
  15. data/lib/coinbase/client/api/wallets_api.rb +1 -1
  16. data/lib/coinbase/client/api/webhooks_api.rb +1 -1
  17. data/lib/coinbase/client/api_client.rb +1 -1
  18. data/lib/coinbase/client/api_error.rb +1 -1
  19. data/lib/coinbase/client/configuration.rb +1 -11
  20. data/lib/coinbase/client/models/address.rb +1 -1
  21. data/lib/coinbase/client/models/address_balance_list.rb +1 -1
  22. data/lib/coinbase/client/models/address_historical_balance_list.rb +258 -0
  23. data/lib/coinbase/client/models/address_list.rb +1 -1
  24. data/lib/coinbase/client/models/asset.rb +1 -1
  25. data/lib/coinbase/client/models/balance.rb +1 -1
  26. data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +1 -1
  27. data/lib/coinbase/client/models/broadcast_trade_request.rb +1 -1
  28. data/lib/coinbase/client/models/broadcast_transfer_request.rb +1 -1
  29. data/lib/coinbase/client/models/build_staking_operation_request.rb +1 -1
  30. data/lib/coinbase/client/models/contract_event.rb +1 -1
  31. data/lib/coinbase/client/models/contract_event_list.rb +1 -1
  32. data/lib/coinbase/client/models/create_address_request.rb +1 -1
  33. data/lib/coinbase/client/models/create_server_signer_request.rb +1 -1
  34. data/lib/coinbase/client/models/create_staking_operation_request.rb +1 -1
  35. data/lib/coinbase/client/models/create_trade_request.rb +1 -1
  36. data/lib/coinbase/client/models/create_transfer_request.rb +15 -5
  37. data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
  38. data/lib/coinbase/client/models/create_wallet_request_wallet.rb +1 -1
  39. data/lib/coinbase/client/models/create_webhook_request.rb +1 -1
  40. data/lib/coinbase/client/models/error.rb +1 -1
  41. data/lib/coinbase/client/models/ethereum_validator.rb +374 -0
  42. data/lib/coinbase/client/models/ethereum_validator_metadata.rb +1 -1
  43. data/lib/coinbase/client/models/faucet_transaction.rb +1 -1
  44. data/lib/coinbase/client/models/feature.rb +1 -1
  45. data/lib/coinbase/client/models/feature_set.rb +307 -0
  46. data/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +258 -0
  47. data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +1 -1
  48. data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +1 -1
  49. data/lib/coinbase/client/models/get_staking_context_request.rb +1 -1
  50. data/lib/coinbase/client/models/get_validator200_response.rb +221 -0
  51. data/lib/coinbase/client/models/get_validator200_response_validator.rb +214 -0
  52. data/lib/coinbase/client/models/historical_balance.rb +273 -0
  53. data/lib/coinbase/client/models/native_eth_staking_context.rb +1 -1
  54. data/lib/coinbase/client/models/network.rb +355 -0
  55. data/lib/coinbase/client/models/network_identifier.rb +44 -0
  56. data/lib/coinbase/client/models/partial_eth_staking_context.rb +1 -1
  57. data/lib/coinbase/client/models/seed_creation_event.rb +1 -1
  58. data/lib/coinbase/client/models/seed_creation_event_result.rb +1 -1
  59. data/lib/coinbase/client/models/server_signer.rb +1 -1
  60. data/lib/coinbase/client/models/server_signer_event.rb +1 -1
  61. data/lib/coinbase/client/models/server_signer_event_event.rb +1 -1
  62. data/lib/coinbase/client/models/server_signer_event_list.rb +1 -1
  63. data/lib/coinbase/client/models/server_signer_list.rb +1 -1
  64. data/lib/coinbase/client/models/signature_creation_event.rb +1 -1
  65. data/lib/coinbase/client/models/signature_creation_event_result.rb +1 -1
  66. data/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb +1 -1
  67. data/lib/coinbase/client/models/sponsored_send.rb +338 -0
  68. data/lib/coinbase/client/models/staking_balance.rb +289 -0
  69. data/lib/coinbase/client/models/staking_context.rb +1 -1
  70. data/lib/coinbase/client/models/staking_context_context.rb +223 -75
  71. data/lib/coinbase/client/models/staking_operation.rb +3 -3
  72. data/lib/coinbase/client/models/staking_operation_metadata.rb +1 -1
  73. data/lib/coinbase/client/models/staking_reward.rb +23 -7
  74. data/lib/coinbase/client/models/staking_reward_format.rb +3 -2
  75. data/lib/coinbase/client/models/staking_reward_usd_value.rb +257 -0
  76. data/lib/coinbase/client/models/trade.rb +1 -1
  77. data/lib/coinbase/client/models/trade_list.rb +1 -1
  78. data/lib/coinbase/client/models/transaction.rb +3 -3
  79. data/lib/coinbase/client/models/transaction_type.rb +3 -2
  80. data/lib/coinbase/client/models/transfer.rb +102 -9
  81. data/lib/coinbase/client/models/transfer_list.rb +1 -1
  82. data/lib/coinbase/client/models/update_webhook_request.rb +1 -1
  83. data/lib/coinbase/client/models/user.rb +1 -1
  84. data/lib/coinbase/client/models/validator.rb +1 -1
  85. data/lib/coinbase/client/models/validator_details.rb +1 -1
  86. data/lib/coinbase/client/models/validator_list.rb +1 -1
  87. data/lib/coinbase/client/models/validator_list_data.rb +216 -0
  88. data/lib/coinbase/client/models/wallet.rb +14 -17
  89. data/lib/coinbase/client/models/wallet_list.rb +1 -1
  90. data/lib/coinbase/client/models/webhook.rb +1 -1
  91. data/lib/coinbase/client/models/webhook_event_filter.rb +1 -1
  92. data/lib/coinbase/client/models/webhook_event_type.rb +3 -2
  93. data/lib/coinbase/client/models/webhook_list.rb +1 -1
  94. data/lib/coinbase/client/version.rb +1 -1
  95. data/lib/coinbase/client.rb +11 -4
  96. data/lib/coinbase/errors.rb +7 -0
  97. data/lib/coinbase/historical_balance.rb +53 -0
  98. data/lib/coinbase/server_signer.rb +14 -3
  99. data/lib/coinbase/sponsored_send.rb +110 -0
  100. data/lib/coinbase/staking_balance.rb +86 -0
  101. data/lib/coinbase/staking_reward.rb +18 -0
  102. data/lib/coinbase/transaction.rb +7 -3
  103. data/lib/coinbase/transfer.rb +56 -28
  104. data/lib/coinbase/wallet/data.rb +31 -0
  105. data/lib/coinbase/wallet.rb +15 -46
  106. data/lib/coinbase.rb +15 -3
  107. metadata +48 -2
@@ -0,0 +1,216 @@
1
+ =begin
2
+ #Coinbase Platform API
3
+
4
+ #This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
5
+
6
+ The version of the OpenAPI document: 0.0.1-alpha
7
+ Contact: yuga.cohler@coinbase.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ class ValidatorListData
18
+ attr_accessor :ethereum_validators
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'ethereum_validators' => :'ethereum_validators'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'ethereum_validators' => :'Array<EthereumValidator>'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::ValidatorListData` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::ValidatorListData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'ethereum_validators')
61
+ if (value = attributes[:'ethereum_validators']).is_a?(Array)
62
+ self.ethereum_validators = value
63
+ end
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
71
+ invalid_properties = Array.new
72
+ invalid_properties
73
+ end
74
+
75
+ # Check to see if the all the properties in the model are valid
76
+ # @return true if the model is valid
77
+ def valid?
78
+ warn '[DEPRECATED] the `valid?` method is obsolete'
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ ethereum_validators == o.ethereum_validators
88
+ end
89
+
90
+ # @see the `==` method
91
+ # @param [Object] Object to be compared
92
+ def eql?(o)
93
+ self == o
94
+ end
95
+
96
+ # Calculates hash code according to all attributes.
97
+ # @return [Integer] Hash code
98
+ def hash
99
+ [ethereum_validators].hash
100
+ end
101
+
102
+ # Builds the object from hash
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ # @return [Object] Returns the model itself
105
+ def self.build_from_hash(attributes)
106
+ return nil unless attributes.is_a?(Hash)
107
+ attributes = attributes.transform_keys(&:to_sym)
108
+ transformed_hash = {}
109
+ openapi_types.each_pair do |key, type|
110
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
111
+ transformed_hash["#{key}"] = nil
112
+ elsif type =~ /\AArray<(.*)>/i
113
+ # check to ensure the input is an array given that the attribute
114
+ # is documented as an array but the input is not
115
+ if attributes[attribute_map[key]].is_a?(Array)
116
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
117
+ end
118
+ elsif !attributes[attribute_map[key]].nil?
119
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
120
+ end
121
+ end
122
+ new(transformed_hash)
123
+ end
124
+
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
129
+ def self._deserialize(type, value)
130
+ case type.to_sym
131
+ when :Time
132
+ Time.parse(value)
133
+ when :Date
134
+ Date.parse(value)
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :Boolean
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
150
+ when /\AArray<(?<inner_type>.+)>\z/
151
+ inner_type = Regexp.last_match[:inner_type]
152
+ value.map { |v| _deserialize(inner_type, v) }
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
+ k_type = Regexp.last_match[:k_type]
155
+ v_type = Regexp.last_match[:v_type]
156
+ {}.tap do |hash|
157
+ value.each do |k, v|
158
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
+ end
160
+ end
161
+ else # model
162
+ # models (e.g. Pet) or oneOf
163
+ klass = Coinbase::Client.const_get(type)
164
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
165
+ end
166
+ end
167
+
168
+ # Returns the string representation of the object
169
+ # @return [String] String presentation of the object
170
+ def to_s
171
+ to_hash.to_s
172
+ end
173
+
174
+ # to_body is an alias to to_hash (backward compatibility)
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_body
177
+ to_hash
178
+ end
179
+
180
+ # Returns the object in the form of hash
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_hash
183
+ hash = {}
184
+ self.class.attribute_map.each_pair do |attr, param|
185
+ value = self.send(attr)
186
+ if value.nil?
187
+ is_nullable = self.class.openapi_nullable.include?(attr)
188
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
189
+ end
190
+
191
+ hash[param] = _to_hash(value)
192
+ end
193
+ hash
194
+ end
195
+
196
+ # Outputs non-array value in the form of hash
197
+ # For object, use to_hash. Otherwise, just return the value
198
+ # @param [Object] value Any valid value
199
+ # @return [Hash] Returns the value in the form of hash
200
+ def _to_hash(value)
201
+ if value.is_a?(Array)
202
+ value.compact.map { |v| _to_hash(v) }
203
+ elsif value.is_a?(Hash)
204
+ {}.tap do |hash|
205
+ value.each { |k, v| hash[k] = _to_hash(v) }
206
+ end
207
+ elsif value.respond_to? :to_hash
208
+ value.to_hash
209
+ else
210
+ value
211
+ end
212
+ end
213
+
214
+ end
215
+
216
+ end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -23,8 +23,7 @@ module Coinbase::Client
23
23
 
24
24
  attr_accessor :default_address
25
25
 
26
- # The features enabled for the wallet
27
- attr_accessor :enabled_features
26
+ attr_accessor :feature_set
28
27
 
29
28
  # The status of the Server-Signer for the wallet if present.
30
29
  attr_accessor :server_signer_status
@@ -57,7 +56,7 @@ module Coinbase::Client
57
56
  :'id' => :'id',
58
57
  :'network_id' => :'network_id',
59
58
  :'default_address' => :'default_address',
60
- :'enabled_features' => :'enabled_features',
59
+ :'feature_set' => :'feature_set',
61
60
  :'server_signer_status' => :'server_signer_status'
62
61
  }
63
62
  end
@@ -73,7 +72,7 @@ module Coinbase::Client
73
72
  :'id' => :'String',
74
73
  :'network_id' => :'String',
75
74
  :'default_address' => :'Address',
76
- :'enabled_features' => :'Array<Feature>',
75
+ :'feature_set' => :'FeatureSet',
77
76
  :'server_signer_status' => :'String'
78
77
  }
79
78
  end
@@ -115,12 +114,10 @@ module Coinbase::Client
115
114
  self.default_address = attributes[:'default_address']
116
115
  end
117
116
 
118
- if attributes.key?(:'enabled_features')
119
- if (value = attributes[:'enabled_features']).is_a?(Array)
120
- self.enabled_features = value
121
- end
117
+ if attributes.key?(:'feature_set')
118
+ self.feature_set = attributes[:'feature_set']
122
119
  else
123
- self.enabled_features = nil
120
+ self.feature_set = nil
124
121
  end
125
122
 
126
123
  if attributes.key?(:'server_signer_status')
@@ -141,8 +138,8 @@ module Coinbase::Client
141
138
  invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
142
139
  end
143
140
 
144
- if @enabled_features.nil?
145
- invalid_properties.push('invalid value for "enabled_features", enabled_features cannot be nil.')
141
+ if @feature_set.nil?
142
+ invalid_properties.push('invalid value for "feature_set", feature_set cannot be nil.')
146
143
  end
147
144
 
148
145
  invalid_properties
@@ -154,8 +151,8 @@ module Coinbase::Client
154
151
  warn '[DEPRECATED] the `valid?` method is obsolete'
155
152
  return false if @id.nil?
156
153
  return false if @network_id.nil?
157
- return false if @enabled_features.nil?
158
- server_signer_status_validator = EnumAttributeValidator.new('String', ["pending_seed_creation", "active_seed"])
154
+ return false if @feature_set.nil?
155
+ server_signer_status_validator = EnumAttributeValidator.new('String', ["pending_seed_creation", "active_seed", "unknown_default_open_api"])
159
156
  return false unless server_signer_status_validator.valid?(@server_signer_status)
160
157
  true
161
158
  end
@@ -163,7 +160,7 @@ module Coinbase::Client
163
160
  # Custom attribute writer method checking allowed values (enum).
164
161
  # @param [Object] server_signer_status Object to be assigned
165
162
  def server_signer_status=(server_signer_status)
166
- validator = EnumAttributeValidator.new('String', ["pending_seed_creation", "active_seed"])
163
+ validator = EnumAttributeValidator.new('String', ["pending_seed_creation", "active_seed", "unknown_default_open_api"])
167
164
  unless validator.valid?(server_signer_status)
168
165
  fail ArgumentError, "invalid value for \"server_signer_status\", must be one of #{validator.allowable_values}."
169
166
  end
@@ -178,7 +175,7 @@ module Coinbase::Client
178
175
  id == o.id &&
179
176
  network_id == o.network_id &&
180
177
  default_address == o.default_address &&
181
- enabled_features == o.enabled_features &&
178
+ feature_set == o.feature_set &&
182
179
  server_signer_status == o.server_signer_status
183
180
  end
184
181
 
@@ -191,7 +188,7 @@ module Coinbase::Client
191
188
  # Calculates hash code according to all attributes.
192
189
  # @return [Integer] Hash code
193
190
  def hash
194
- [id, network_id, default_address, enabled_features, server_signer_status].hash
191
+ [id, network_id, default_address, feature_set, server_signer_status].hash
195
192
  end
196
193
 
197
194
  # Builds the object from hash
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -18,9 +18,10 @@ module Coinbase::Client
18
18
  UNSPECIFIED = "unspecified".freeze
19
19
  ERC20_TRANSFER = "erc20_transfer".freeze
20
20
  ERC721_TRANSFER = "erc721_transfer".freeze
21
+ UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
21
22
 
22
23
  def self.all_vars
23
- @all_vars ||= [UNSPECIFIED, ERC20_TRANSFER, ERC721_TRANSFER].freeze
24
+ @all_vars ||= [UNSPECIFIED, ERC20_TRANSFER, ERC721_TRANSFER, UNKNOWN_DEFAULT_OPEN_API].freeze
24
25
  end
25
26
 
26
27
  # Builds the enum from string
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -19,6 +19,7 @@ require 'coinbase/client/configuration'
19
19
  # Models
20
20
  Coinbase::Client.autoload :Address, 'coinbase/client/models/address'
21
21
  Coinbase::Client.autoload :AddressBalanceList, 'coinbase/client/models/address_balance_list'
22
+ Coinbase::Client.autoload :AddressHistoricalBalanceList, 'coinbase/client/models/address_historical_balance_list'
22
23
  Coinbase::Client.autoload :AddressList, 'coinbase/client/models/address_list'
23
24
  Coinbase::Client.autoload :Asset, 'coinbase/client/models/asset'
24
25
  Coinbase::Client.autoload :Balance, 'coinbase/client/models/balance'
@@ -39,12 +40,14 @@ Coinbase::Client.autoload :CreateWebhookRequest, 'coinbase/client/models/create_
39
40
  Coinbase::Client.autoload :Error, 'coinbase/client/models/error'
40
41
  Coinbase::Client.autoload :EthereumValidatorMetadata, 'coinbase/client/models/ethereum_validator_metadata'
41
42
  Coinbase::Client.autoload :FaucetTransaction, 'coinbase/client/models/faucet_transaction'
42
- Coinbase::Client.autoload :Feature, 'coinbase/client/models/feature'
43
+ Coinbase::Client.autoload :FeatureSet, 'coinbase/client/models/feature_set'
44
+ Coinbase::Client.autoload :FetchHistoricalStakingBalances200Response, 'coinbase/client/models/fetch_historical_staking_balances200_response'
43
45
  Coinbase::Client.autoload :FetchStakingRewards200Response, 'coinbase/client/models/fetch_staking_rewards200_response'
44
46
  Coinbase::Client.autoload :FetchStakingRewardsRequest, 'coinbase/client/models/fetch_staking_rewards_request'
45
47
  Coinbase::Client.autoload :GetStakingContextRequest, 'coinbase/client/models/get_staking_context_request'
46
- Coinbase::Client.autoload :NativeEthStakingContext, 'coinbase/client/models/native_eth_staking_context'
47
- Coinbase::Client.autoload :PartialEthStakingContext, 'coinbase/client/models/partial_eth_staking_context'
48
+ Coinbase::Client.autoload :HistoricalBalance, 'coinbase/client/models/historical_balance'
49
+ Coinbase::Client.autoload :Network, 'coinbase/client/models/network'
50
+ Coinbase::Client.autoload :NetworkIdentifier, 'coinbase/client/models/network_identifier'
48
51
  Coinbase::Client.autoload :SeedCreationEvent, 'coinbase/client/models/seed_creation_event'
49
52
  Coinbase::Client.autoload :SeedCreationEventResult, 'coinbase/client/models/seed_creation_event_result'
50
53
  Coinbase::Client.autoload :ServerSigner, 'coinbase/client/models/server_signer'
@@ -55,12 +58,15 @@ Coinbase::Client.autoload :ServerSignerList, 'coinbase/client/models/server_sign
55
58
  Coinbase::Client.autoload :SignatureCreationEvent, 'coinbase/client/models/signature_creation_event'
56
59
  Coinbase::Client.autoload :SignatureCreationEventResult, 'coinbase/client/models/signature_creation_event_result'
57
60
  Coinbase::Client.autoload :SignedVoluntaryExitMessageMetadata, 'coinbase/client/models/signed_voluntary_exit_message_metadata'
61
+ Coinbase::Client.autoload :SponsoredSend, 'coinbase/client/models/sponsored_send'
62
+ Coinbase::Client.autoload :StakingBalance, 'coinbase/client/models/staking_balance'
58
63
  Coinbase::Client.autoload :StakingContext, 'coinbase/client/models/staking_context'
59
64
  Coinbase::Client.autoload :StakingContextContext, 'coinbase/client/models/staking_context_context'
60
65
  Coinbase::Client.autoload :StakingOperation, 'coinbase/client/models/staking_operation'
61
66
  Coinbase::Client.autoload :StakingOperationMetadata, 'coinbase/client/models/staking_operation_metadata'
62
67
  Coinbase::Client.autoload :StakingReward, 'coinbase/client/models/staking_reward'
63
68
  Coinbase::Client.autoload :StakingRewardFormat, 'coinbase/client/models/staking_reward_format'
69
+ Coinbase::Client.autoload :StakingRewardUSDValue, 'coinbase/client/models/staking_reward_usd_value'
64
70
  Coinbase::Client.autoload :Trade, 'coinbase/client/models/trade'
65
71
  Coinbase::Client.autoload :TradeList, 'coinbase/client/models/trade_list'
66
72
  Coinbase::Client.autoload :Transaction, 'coinbase/client/models/transaction'
@@ -84,6 +90,7 @@ Coinbase::Client.autoload :AddressesApi, 'coinbase/client/api/addresses_api'
84
90
  Coinbase::Client.autoload :AssetsApi, 'coinbase/client/api/assets_api'
85
91
  Coinbase::Client.autoload :ContractEventsApi, 'coinbase/client/api/contract_events_api'
86
92
  Coinbase::Client.autoload :ExternalAddressesApi, 'coinbase/client/api/external_addresses_api'
93
+ Coinbase::Client.autoload :NetworksApi, 'coinbase/client/api/networks_api'
87
94
  Coinbase::Client.autoload :ServerSignersApi, 'coinbase/client/api/server_signers_api'
88
95
  Coinbase::Client.autoload :StakeApi, 'coinbase/client/api/stake_api'
89
96
  Coinbase::Client.autoload :TradesApi, 'coinbase/client/api/trades_api'
@@ -63,6 +63,13 @@ module Coinbase
63
63
  end
64
64
  end
65
65
 
66
+ # An error raised when a resource is already signed.
67
+ class AlreadySignedError < StandardError
68
+ def initialize(msg = 'Resource already signed')
69
+ super(msg)
70
+ end
71
+ end
72
+
66
73
  # An error raised when a transaction is not signed.
67
74
  class TransactionNotSignedError < StandardError
68
75
  def initialize(msg = 'Transaction must be signed')
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coinbase
4
+ # A representation of an HistoricalBalance.
5
+ class HistoricalBalance
6
+ # Converts a Coinbase::Client::HistoricalBalance model to a Coinbase::HistoricalBalance
7
+ # @param historical_balance_model [Coinbase::Client::HistoricalBalance] The historical balance fetched from the API.
8
+ # @return [HistoricalBalance] The converted HistoricalBalance object.
9
+ def self.from_model(historical_balance_model)
10
+ asset = Coinbase::Asset.from_model(historical_balance_model.asset)
11
+
12
+ new(
13
+ amount: asset.from_atomic_amount(historical_balance_model.amount),
14
+ block_height: BigDecimal(historical_balance_model.block_height),
15
+ block_hash: historical_balance_model.block_hash,
16
+ asset: asset
17
+ )
18
+ end
19
+
20
+ # Returns a new HistoricalBalance object. Do not use this method. Instead, use Balance.from_model or
21
+ # Balance.from_model_and_asset_id.
22
+ # @param amount [BigDecimal] The amount of the Asset
23
+ # @param block_height [BigDecimal] The block height at which the balance was recorded
24
+ # @param block_hash [String] The block hash at which the balance was recorded
25
+ # @param asset [Asset] The asset we want to fetch
26
+ def initialize(amount:, block_height:, block_hash:, asset:)
27
+ @amount = amount
28
+ @block_height = block_height
29
+ @block_hash = block_hash
30
+ @asset = asset
31
+ end
32
+
33
+ attr_reader :amount, :block_height, :block_hash, :asset
34
+
35
+ # Returns a string representation of the HistoricalBalance.
36
+ # @return [String] a string representation of the HistoricalBalance
37
+ def to_s
38
+ Coinbase.pretty_print_object(
39
+ self.class,
40
+ amount: amount.to_i,
41
+ block_height: block_height.to_i,
42
+ block_hash: block_hash,
43
+ asset: asset
44
+ )
45
+ end
46
+
47
+ # Same as to_s.
48
+ # @return [String] a string representation of the HistoricalBalance
49
+ def inspect
50
+ to_s
51
+ end
52
+ end
53
+ end
@@ -5,9 +5,15 @@ require_relative 'client'
5
5
  module Coinbase
6
6
  # A representation of a Server-Signer. Server-Signers are assigned to sign transactions for a Wallet.
7
7
  class ServerSigner
8
- # Returns a new Server-Signer object. Do not use this method directly. Instead, use ServerSigner.default.
9
- def initialize(model)
10
- @model = model
8
+ # A representation of ServerSigner status in a Wallet.
9
+ module Status
10
+ # The Wallet is awaiting seed creation by the ServerSigner. At this point,
11
+ # the Wallet cannot create addresses or sign transactions.
12
+ PENDING = 'pending_seed_creation'
13
+
14
+ # The Wallet has an associated seed created by the ServerSigner. It is ready
15
+ # to create addresses and sign transactions.
16
+ ACTIVE = 'active_seed'
11
17
  end
12
18
 
13
19
  class << self
@@ -30,6 +36,11 @@ module Coinbase
30
36
  end
31
37
  end
32
38
 
39
+ # Returns a new Server-Signer object. Do not use this method directly. Instead, use ServerSigner.default.
40
+ def initialize(model)
41
+ @model = model
42
+ end
43
+
33
44
  # Returns the Server-Signer ID.
34
45
  # @return [String] the Server-Signer ID
35
46
  def id
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eth'
4
+
5
+ module Coinbase
6
+ # A representation of an onchain Sponsored Send.
7
+ # Sponsored Sends should be constructed via higher level abstractions like Transfer.
8
+ class SponsoredSend
9
+ # A representation of a Transaction status.
10
+ module Status
11
+ # The SponsoredSend is awaiting being signed.
12
+ PENDING = 'pending'
13
+
14
+ # The Sponsored Send has been signed, but has not been submitted to be
15
+ # built into a transaction yet.
16
+ SIGNED = 'signed'
17
+
18
+ # The Sponsored Send has been submitted to be built into a transaction,
19
+ # that the sponsor will sign and submit to the network.
20
+ # At this point, transaction hashes may not yet be assigned.
21
+ SUBMITTED = 'submitted'
22
+
23
+ # The Sponsored Send's corresponding transaction is complete and has
24
+ # confirmed on the Network.
25
+ COMPLETE = 'complete'
26
+
27
+ # The Sponsored Send has failed for some reason.
28
+ FAILED = 'failed'
29
+
30
+ # The states that are considered terminal on-chain.
31
+ TERMINAL_STATES = [COMPLETE, FAILED].freeze
32
+ end
33
+
34
+ # Returns a new SponsoredSend object. Do not use this method directly.
35
+ # @param model [Coinbase::Client::SponsoredSend] The underlying SponsoredSend object
36
+ def initialize(model)
37
+ raise unless model.is_a?(Coinbase::Client::SponsoredSend)
38
+
39
+ @model = model
40
+ end
41
+
42
+ # Returns the Keccak256 hash of the typed data. This payload must be signed
43
+ # by the sender to be used as an approval in the EIP-3009 transaction.
44
+ # @return [String] The Keccak256 hash of the typed data
45
+ def typed_data_hash
46
+ @model.typed_data_hash
47
+ end
48
+
49
+ # Returns the signature of the typed data.
50
+ def signature
51
+ @signature ||= @model.signature
52
+ end
53
+
54
+ # Signs the Transaction with the provided key and returns the hex signing payload.
55
+ # @return [String] The hex-encoded signed payload
56
+ def sign(key)
57
+ raise unless key.is_a?(Eth::Key)
58
+ raise Coinbase::AlreadySignedError if signed?
59
+
60
+ @signature = Eth::Util.prefix_hex(key.sign(Eth::Util.hex_to_bin(typed_data_hash)))
61
+ end
62
+
63
+ # Returns whether the Transaction has been signed.
64
+ # @return [Boolean] Whether the Transaction has been signed
65
+ def signed?
66
+ !signature.nil?
67
+ end
68
+
69
+ # Returns the status of the Transaction.
70
+ # @return [Symbol] The status
71
+ def status
72
+ @model.status
73
+ end
74
+
75
+ # Returns whether the Sponsored Send is in a terminal state.
76
+ # @return [Boolean] Whether the Transaction is in a terminal state
77
+ def terminal_state?
78
+ Status::TERMINAL_STATES.include?(status)
79
+ end
80
+
81
+ # Returns the Transaction Hash of the Transaction.
82
+ # @return [String] The Transaction Hash
83
+ def transaction_hash
84
+ @model.transaction_hash
85
+ end
86
+
87
+ # Returns the link to the transaction on the blockchain explorer.
88
+ # @return [String] The link to the transaction on the blockchain explorer
89
+ def transaction_link
90
+ @model.transaction_link
91
+ end
92
+
93
+ # Returns a String representation of the SponsoredSend.
94
+ # @return [String] a String representation of the SponsoredSend
95
+ def to_s
96
+ Coinbase.pretty_print_object(
97
+ self.class,
98
+ status: status,
99
+ transaction_hash: transaction_hash,
100
+ transaction_link: transaction_link
101
+ )
102
+ end
103
+
104
+ # Same as to_s.
105
+ # @return [String] a String representation of the SponsoredSend
106
+ def inspect
107
+ to_s
108
+ end
109
+ end
110
+ end