coinbase-sdk 0.0.13 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coinbase/address/external_address.rb +3 -166
- data/lib/coinbase/address/wallet_address.rb +51 -4
- data/lib/coinbase/address.rb +164 -0
- data/lib/coinbase/client/api/assets_api.rb +2 -2
- data/lib/coinbase/client/api/contract_events_api.rb +121 -0
- data/lib/coinbase/client/api/external_addresses_api.rb +85 -0
- data/lib/coinbase/client/api/networks_api.rb +85 -0
- data/lib/coinbase/client/api/stake_api.rb +361 -0
- data/lib/coinbase/client/api/webhooks_api.rb +286 -0
- data/lib/coinbase/client/models/address_historical_balance_list.rb +258 -0
- data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +239 -0
- data/lib/coinbase/client/models/contract_event.rb +336 -0
- data/lib/coinbase/client/models/contract_event_list.rb +259 -0
- data/lib/coinbase/client/models/create_staking_operation_request.rb +274 -0
- data/lib/coinbase/client/models/create_transfer_request.rb +14 -4
- data/lib/coinbase/client/models/create_webhook_request.rb +282 -0
- data/lib/coinbase/client/models/ethereum_validator.rb +374 -0
- data/lib/coinbase/client/models/feature_set.rb +307 -0
- data/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +258 -0
- data/lib/coinbase/client/models/get_validator200_response.rb +221 -0
- data/lib/coinbase/client/models/get_validator200_response_validator.rb +214 -0
- data/lib/coinbase/client/models/historical_balance.rb +273 -0
- data/lib/coinbase/client/models/network.rb +355 -0
- data/lib/coinbase/client/models/network_identifier.rb +44 -0
- data/lib/coinbase/client/models/sponsored_send.rb +338 -0
- data/lib/coinbase/client/models/staking_balance.rb +289 -0
- data/lib/coinbase/client/models/staking_context_context.rb +222 -74
- data/lib/coinbase/client/models/staking_operation.rb +15 -5
- data/lib/coinbase/client/models/staking_reward.rb +22 -6
- data/lib/coinbase/client/models/staking_reward_format.rb +2 -1
- data/lib/coinbase/client/models/staking_reward_usd_value.rb +257 -0
- data/lib/coinbase/client/models/transaction.rb +2 -2
- data/lib/coinbase/client/models/transaction_type.rb +2 -1
- data/lib/coinbase/client/models/transfer.rb +29 -24
- data/lib/coinbase/client/models/update_webhook_request.rb +289 -0
- data/lib/coinbase/client/models/validator_list_data.rb +216 -0
- data/lib/coinbase/client/models/wallet.rb +13 -16
- data/lib/coinbase/client/models/webhook.rb +299 -0
- data/lib/coinbase/client/models/webhook_event_filter.rb +236 -0
- data/lib/coinbase/client/models/webhook_event_type.rb +42 -0
- data/lib/coinbase/client/models/webhook_list.rb +244 -0
- data/lib/coinbase/client.rb +22 -3
- data/lib/coinbase/errors.rb +7 -0
- data/lib/coinbase/historical_balance.rb +53 -0
- data/lib/coinbase/middleware.rb +12 -0
- data/lib/coinbase/server_signer.rb +14 -3
- data/lib/coinbase/sponsored_send.rb +110 -0
- data/lib/coinbase/staking_balance.rb +86 -0
- data/lib/coinbase/staking_operation.rb +106 -5
- data/lib/coinbase/staking_reward.rb +18 -0
- data/lib/coinbase/trade.rb +1 -1
- data/lib/coinbase/transaction.rb +7 -3
- data/lib/coinbase/transfer.rb +56 -29
- data/lib/coinbase/wallet/data.rb +31 -0
- data/lib/coinbase/wallet.rb +91 -46
- data/lib/coinbase.rb +17 -4
- metadata +74 -2
@@ -0,0 +1,355 @@
|
|
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 Network
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
# The human-readable name of the blockchain network
|
21
|
+
attr_accessor :display_name
|
22
|
+
|
23
|
+
# The chain ID of the blockchain network
|
24
|
+
attr_accessor :chain_id
|
25
|
+
|
26
|
+
# The protocol family of the blockchain network
|
27
|
+
attr_accessor :protocol_family
|
28
|
+
|
29
|
+
# Whether the network is a testnet or not
|
30
|
+
attr_accessor :is_testnet
|
31
|
+
|
32
|
+
attr_accessor :native_asset
|
33
|
+
|
34
|
+
attr_accessor :feature_set
|
35
|
+
|
36
|
+
class EnumAttributeValidator
|
37
|
+
attr_reader :datatype
|
38
|
+
attr_reader :allowable_values
|
39
|
+
|
40
|
+
def initialize(datatype, allowable_values)
|
41
|
+
@allowable_values = allowable_values.map do |value|
|
42
|
+
case datatype.to_s
|
43
|
+
when /Integer/i
|
44
|
+
value.to_i
|
45
|
+
when /Float/i
|
46
|
+
value.to_f
|
47
|
+
else
|
48
|
+
value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def valid?(value)
|
54
|
+
!value || allowable_values.include?(value)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
59
|
+
def self.attribute_map
|
60
|
+
{
|
61
|
+
:'id' => :'id',
|
62
|
+
:'display_name' => :'display_name',
|
63
|
+
:'chain_id' => :'chain_id',
|
64
|
+
:'protocol_family' => :'protocol_family',
|
65
|
+
:'is_testnet' => :'is_testnet',
|
66
|
+
:'native_asset' => :'native_asset',
|
67
|
+
:'feature_set' => :'feature_set'
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns all the JSON keys this model knows about
|
72
|
+
def self.acceptable_attributes
|
73
|
+
attribute_map.values
|
74
|
+
end
|
75
|
+
|
76
|
+
# Attribute type mapping.
|
77
|
+
def self.openapi_types
|
78
|
+
{
|
79
|
+
:'id' => :'NetworkIdentifier',
|
80
|
+
:'display_name' => :'String',
|
81
|
+
:'chain_id' => :'Integer',
|
82
|
+
:'protocol_family' => :'String',
|
83
|
+
:'is_testnet' => :'Boolean',
|
84
|
+
:'native_asset' => :'Asset',
|
85
|
+
:'feature_set' => :'FeatureSet'
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
# List of attributes with nullable: true
|
90
|
+
def self.openapi_nullable
|
91
|
+
Set.new([
|
92
|
+
])
|
93
|
+
end
|
94
|
+
|
95
|
+
# Initializes the object
|
96
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
97
|
+
def initialize(attributes = {})
|
98
|
+
if (!attributes.is_a?(Hash))
|
99
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Network` initialize method"
|
100
|
+
end
|
101
|
+
|
102
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
103
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
104
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
105
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::Network`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
106
|
+
end
|
107
|
+
h[k.to_sym] = v
|
108
|
+
}
|
109
|
+
|
110
|
+
if attributes.key?(:'id')
|
111
|
+
self.id = attributes[:'id']
|
112
|
+
else
|
113
|
+
self.id = nil
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:'display_name')
|
117
|
+
self.display_name = attributes[:'display_name']
|
118
|
+
else
|
119
|
+
self.display_name = nil
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.key?(:'chain_id')
|
123
|
+
self.chain_id = attributes[:'chain_id']
|
124
|
+
else
|
125
|
+
self.chain_id = nil
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'protocol_family')
|
129
|
+
self.protocol_family = attributes[:'protocol_family']
|
130
|
+
else
|
131
|
+
self.protocol_family = nil
|
132
|
+
end
|
133
|
+
|
134
|
+
if attributes.key?(:'is_testnet')
|
135
|
+
self.is_testnet = attributes[:'is_testnet']
|
136
|
+
else
|
137
|
+
self.is_testnet = nil
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.key?(:'native_asset')
|
141
|
+
self.native_asset = attributes[:'native_asset']
|
142
|
+
else
|
143
|
+
self.native_asset = nil
|
144
|
+
end
|
145
|
+
|
146
|
+
if attributes.key?(:'feature_set')
|
147
|
+
self.feature_set = attributes[:'feature_set']
|
148
|
+
else
|
149
|
+
self.feature_set = nil
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
154
|
+
# @return Array for valid properties with the reasons
|
155
|
+
def list_invalid_properties
|
156
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
157
|
+
invalid_properties = Array.new
|
158
|
+
if @id.nil?
|
159
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
160
|
+
end
|
161
|
+
|
162
|
+
if @display_name.nil?
|
163
|
+
invalid_properties.push('invalid value for "display_name", display_name cannot be nil.')
|
164
|
+
end
|
165
|
+
|
166
|
+
if @chain_id.nil?
|
167
|
+
invalid_properties.push('invalid value for "chain_id", chain_id cannot be nil.')
|
168
|
+
end
|
169
|
+
|
170
|
+
if @protocol_family.nil?
|
171
|
+
invalid_properties.push('invalid value for "protocol_family", protocol_family cannot be nil.')
|
172
|
+
end
|
173
|
+
|
174
|
+
if @is_testnet.nil?
|
175
|
+
invalid_properties.push('invalid value for "is_testnet", is_testnet cannot be nil.')
|
176
|
+
end
|
177
|
+
|
178
|
+
if @native_asset.nil?
|
179
|
+
invalid_properties.push('invalid value for "native_asset", native_asset cannot be nil.')
|
180
|
+
end
|
181
|
+
|
182
|
+
if @feature_set.nil?
|
183
|
+
invalid_properties.push('invalid value for "feature_set", feature_set cannot be nil.')
|
184
|
+
end
|
185
|
+
|
186
|
+
invalid_properties
|
187
|
+
end
|
188
|
+
|
189
|
+
# Check to see if the all the properties in the model are valid
|
190
|
+
# @return true if the model is valid
|
191
|
+
def valid?
|
192
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
193
|
+
return false if @id.nil?
|
194
|
+
return false if @display_name.nil?
|
195
|
+
return false if @chain_id.nil?
|
196
|
+
return false if @protocol_family.nil?
|
197
|
+
protocol_family_validator = EnumAttributeValidator.new('String', ["evm", "unknown_default_open_api"])
|
198
|
+
return false unless protocol_family_validator.valid?(@protocol_family)
|
199
|
+
return false if @is_testnet.nil?
|
200
|
+
return false if @native_asset.nil?
|
201
|
+
return false if @feature_set.nil?
|
202
|
+
true
|
203
|
+
end
|
204
|
+
|
205
|
+
# Custom attribute writer method checking allowed values (enum).
|
206
|
+
# @param [Object] protocol_family Object to be assigned
|
207
|
+
def protocol_family=(protocol_family)
|
208
|
+
validator = EnumAttributeValidator.new('String', ["evm", "unknown_default_open_api"])
|
209
|
+
unless validator.valid?(protocol_family)
|
210
|
+
fail ArgumentError, "invalid value for \"protocol_family\", must be one of #{validator.allowable_values}."
|
211
|
+
end
|
212
|
+
@protocol_family = protocol_family
|
213
|
+
end
|
214
|
+
|
215
|
+
# Checks equality by comparing each attribute.
|
216
|
+
# @param [Object] Object to be compared
|
217
|
+
def ==(o)
|
218
|
+
return true if self.equal?(o)
|
219
|
+
self.class == o.class &&
|
220
|
+
id == o.id &&
|
221
|
+
display_name == o.display_name &&
|
222
|
+
chain_id == o.chain_id &&
|
223
|
+
protocol_family == o.protocol_family &&
|
224
|
+
is_testnet == o.is_testnet &&
|
225
|
+
native_asset == o.native_asset &&
|
226
|
+
feature_set == o.feature_set
|
227
|
+
end
|
228
|
+
|
229
|
+
# @see the `==` method
|
230
|
+
# @param [Object] Object to be compared
|
231
|
+
def eql?(o)
|
232
|
+
self == o
|
233
|
+
end
|
234
|
+
|
235
|
+
# Calculates hash code according to all attributes.
|
236
|
+
# @return [Integer] Hash code
|
237
|
+
def hash
|
238
|
+
[id, display_name, chain_id, protocol_family, is_testnet, native_asset, feature_set].hash
|
239
|
+
end
|
240
|
+
|
241
|
+
# Builds the object from hash
|
242
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
243
|
+
# @return [Object] Returns the model itself
|
244
|
+
def self.build_from_hash(attributes)
|
245
|
+
return nil unless attributes.is_a?(Hash)
|
246
|
+
attributes = attributes.transform_keys(&:to_sym)
|
247
|
+
transformed_hash = {}
|
248
|
+
openapi_types.each_pair do |key, type|
|
249
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
250
|
+
transformed_hash["#{key}"] = nil
|
251
|
+
elsif type =~ /\AArray<(.*)>/i
|
252
|
+
# check to ensure the input is an array given that the attribute
|
253
|
+
# is documented as an array but the input is not
|
254
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
255
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
256
|
+
end
|
257
|
+
elsif !attributes[attribute_map[key]].nil?
|
258
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
259
|
+
end
|
260
|
+
end
|
261
|
+
new(transformed_hash)
|
262
|
+
end
|
263
|
+
|
264
|
+
# Deserializes the data based on type
|
265
|
+
# @param string type Data type
|
266
|
+
# @param string value Value to be deserialized
|
267
|
+
# @return [Object] Deserialized data
|
268
|
+
def self._deserialize(type, value)
|
269
|
+
case type.to_sym
|
270
|
+
when :Time
|
271
|
+
Time.parse(value)
|
272
|
+
when :Date
|
273
|
+
Date.parse(value)
|
274
|
+
when :String
|
275
|
+
value.to_s
|
276
|
+
when :Integer
|
277
|
+
value.to_i
|
278
|
+
when :Float
|
279
|
+
value.to_f
|
280
|
+
when :Boolean
|
281
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
282
|
+
true
|
283
|
+
else
|
284
|
+
false
|
285
|
+
end
|
286
|
+
when :Object
|
287
|
+
# generic object (usually a Hash), return directly
|
288
|
+
value
|
289
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
290
|
+
inner_type = Regexp.last_match[:inner_type]
|
291
|
+
value.map { |v| _deserialize(inner_type, v) }
|
292
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
293
|
+
k_type = Regexp.last_match[:k_type]
|
294
|
+
v_type = Regexp.last_match[:v_type]
|
295
|
+
{}.tap do |hash|
|
296
|
+
value.each do |k, v|
|
297
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
else # model
|
301
|
+
# models (e.g. Pet) or oneOf
|
302
|
+
klass = Coinbase::Client.const_get(type)
|
303
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
# Returns the string representation of the object
|
308
|
+
# @return [String] String presentation of the object
|
309
|
+
def to_s
|
310
|
+
to_hash.to_s
|
311
|
+
end
|
312
|
+
|
313
|
+
# to_body is an alias to to_hash (backward compatibility)
|
314
|
+
# @return [Hash] Returns the object in the form of hash
|
315
|
+
def to_body
|
316
|
+
to_hash
|
317
|
+
end
|
318
|
+
|
319
|
+
# Returns the object in the form of hash
|
320
|
+
# @return [Hash] Returns the object in the form of hash
|
321
|
+
def to_hash
|
322
|
+
hash = {}
|
323
|
+
self.class.attribute_map.each_pair do |attr, param|
|
324
|
+
value = self.send(attr)
|
325
|
+
if value.nil?
|
326
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
327
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
328
|
+
end
|
329
|
+
|
330
|
+
hash[param] = _to_hash(value)
|
331
|
+
end
|
332
|
+
hash
|
333
|
+
end
|
334
|
+
|
335
|
+
# Outputs non-array value in the form of hash
|
336
|
+
# For object, use to_hash. Otherwise, just return the value
|
337
|
+
# @param [Object] value Any valid value
|
338
|
+
# @return [Hash] Returns the value in the form of hash
|
339
|
+
def _to_hash(value)
|
340
|
+
if value.is_a?(Array)
|
341
|
+
value.compact.map { |v| _to_hash(v) }
|
342
|
+
elsif value.is_a?(Hash)
|
343
|
+
{}.tap do |hash|
|
344
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
345
|
+
end
|
346
|
+
elsif value.respond_to? :to_hash
|
347
|
+
value.to_hash
|
348
|
+
else
|
349
|
+
value
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
end
|
354
|
+
|
355
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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 NetworkIdentifier
|
18
|
+
BASE_SEPOLIA = "base-sepolia".freeze
|
19
|
+
BASE_MAINNET = "base-mainnet".freeze
|
20
|
+
ETHEREUM_HOLESKY = "ethereum-holesky".freeze
|
21
|
+
ETHEREUM_MAINNET = "ethereum-mainnet".freeze
|
22
|
+
POLYGON_MAINNET = "polygon-mainnet".freeze
|
23
|
+
UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
|
24
|
+
|
25
|
+
def self.all_vars
|
26
|
+
@all_vars ||= [BASE_SEPOLIA, BASE_MAINNET, ETHEREUM_HOLESKY, ETHEREUM_MAINNET, POLYGON_MAINNET, UNKNOWN_DEFAULT_OPEN_API].freeze
|
27
|
+
end
|
28
|
+
|
29
|
+
# Builds the enum from string
|
30
|
+
# @param [String] The enum value in the form of the string
|
31
|
+
# @return [String] The enum value
|
32
|
+
def self.build_from_hash(value)
|
33
|
+
new.build_from_hash(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Builds the enum from string
|
37
|
+
# @param [String] The enum value in the form of the string
|
38
|
+
# @return [String] The enum value
|
39
|
+
def build_from_hash(value)
|
40
|
+
return value if NetworkIdentifier.all_vars.include?(value)
|
41
|
+
raise "Invalid ENUM value #{value} for class #NetworkIdentifier"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|