coinbase-sdk 0.5.0 → 0.6.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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +26 -1
  3. data/lib/coinbase/client/api/smart_contracts_api.rb +332 -0
  4. data/lib/coinbase/client/api/stake_api.rb +0 -8
  5. data/lib/coinbase/client/api/users_api.rb +79 -0
  6. data/lib/coinbase/client/api/validators_api.rb +4 -4
  7. data/lib/coinbase/client/api/wallets_api.rb +4 -4
  8. data/lib/coinbase/client/models/create_smart_contract_request.rb +259 -0
  9. data/lib/coinbase/client/models/create_webhook_request.rb +10 -8
  10. data/lib/coinbase/client/models/deploy_smart_contract_request.rb +222 -0
  11. data/lib/coinbase/client/models/feature.rb +43 -0
  12. data/lib/coinbase/client/models/nft_contract_options.rb +240 -0
  13. data/lib/coinbase/client/models/smart_contract.rb +378 -0
  14. data/lib/coinbase/client/models/smart_contract_list.rb +257 -0
  15. data/lib/coinbase/client/models/smart_contract_options.rb +106 -0
  16. data/lib/coinbase/client/models/smart_contract_type.rb +41 -0
  17. data/lib/coinbase/client/models/staking_balance.rb +2 -2
  18. data/lib/coinbase/client/models/staking_reward.rb +2 -2
  19. data/lib/coinbase/client/models/token_contract_options.rb +257 -0
  20. data/lib/coinbase/client/models/update_webhook_request.rb +10 -8
  21. data/lib/coinbase/client/models/user.rb +231 -0
  22. data/lib/coinbase/client/models/webhook.rb +10 -1
  23. data/lib/coinbase/client/models/webhook_event_type.rb +2 -1
  24. data/lib/coinbase/client/models/webhook_event_type_filter.rb +105 -0
  25. data/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +228 -0
  26. data/lib/coinbase/client.rb +13 -0
  27. data/lib/coinbase/contract_invocation.rb +16 -17
  28. data/lib/coinbase/smart_contract.rb +216 -45
  29. data/lib/coinbase/transaction.rb +3 -0
  30. data/lib/coinbase/transfer.rb +1 -1
  31. data/lib/coinbase/version.rb +1 -1
  32. data/lib/coinbase/wallet.rb +11 -2
  33. metadata +16 -2
@@ -0,0 +1,240 @@
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
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # Options for NFT contract creation
18
+ class NFTContractOptions
19
+ # The name of the NFT
20
+ attr_accessor :name
21
+
22
+ # The symbol of the NFT
23
+ attr_accessor :symbol
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'name' => :'name',
29
+ :'symbol' => :'symbol'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'name' => :'String',
42
+ :'symbol' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::NFTContractOptions` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::NFTContractOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'name')
68
+ self.name = attributes[:'name']
69
+ else
70
+ self.name = nil
71
+ end
72
+
73
+ if attributes.key?(:'symbol')
74
+ self.symbol = attributes[:'symbol']
75
+ else
76
+ self.symbol = nil
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
84
+ invalid_properties = Array.new
85
+ if @name.nil?
86
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
87
+ end
88
+
89
+ if @symbol.nil?
90
+ invalid_properties.push('invalid value for "symbol", symbol cannot be nil.')
91
+ end
92
+
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ warn '[DEPRECATED] the `valid?` method is obsolete'
100
+ return false if @name.nil?
101
+ return false if @symbol.nil?
102
+ true
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(o)
108
+ return true if self.equal?(o)
109
+ self.class == o.class &&
110
+ name == o.name &&
111
+ symbol == o.symbol
112
+ end
113
+
114
+ # @see the `==` method
115
+ # @param [Object] Object to be compared
116
+ def eql?(o)
117
+ self == o
118
+ end
119
+
120
+ # Calculates hash code according to all attributes.
121
+ # @return [Integer] Hash code
122
+ def hash
123
+ [name, symbol].hash
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def self.build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ attributes = attributes.transform_keys(&:to_sym)
132
+ transformed_hash = {}
133
+ openapi_types.each_pair do |key, type|
134
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
135
+ transformed_hash["#{key}"] = nil
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[attribute_map[key]].is_a?(Array)
140
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
141
+ end
142
+ elsif !attributes[attribute_map[key]].nil?
143
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
144
+ end
145
+ end
146
+ new(transformed_hash)
147
+ end
148
+
149
+ # Deserializes the data based on type
150
+ # @param string type Data type
151
+ # @param string value Value to be deserialized
152
+ # @return [Object] Deserialized data
153
+ def self._deserialize(type, value)
154
+ case type.to_sym
155
+ when :Time
156
+ Time.parse(value)
157
+ when :Date
158
+ Date.parse(value)
159
+ when :String
160
+ value.to_s
161
+ when :Integer
162
+ value.to_i
163
+ when :Float
164
+ value.to_f
165
+ when :Boolean
166
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
167
+ true
168
+ else
169
+ false
170
+ end
171
+ when :Object
172
+ # generic object (usually a Hash), return directly
173
+ value
174
+ when /\AArray<(?<inner_type>.+)>\z/
175
+ inner_type = Regexp.last_match[:inner_type]
176
+ value.map { |v| _deserialize(inner_type, v) }
177
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
178
+ k_type = Regexp.last_match[:k_type]
179
+ v_type = Regexp.last_match[:v_type]
180
+ {}.tap do |hash|
181
+ value.each do |k, v|
182
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
183
+ end
184
+ end
185
+ else # model
186
+ # models (e.g. Pet) or oneOf
187
+ klass = Coinbase::Client.const_get(type)
188
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
189
+ end
190
+ end
191
+
192
+ # Returns the string representation of the object
193
+ # @return [String] String presentation of the object
194
+ def to_s
195
+ to_hash.to_s
196
+ end
197
+
198
+ # to_body is an alias to to_hash (backward compatibility)
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_body
201
+ to_hash
202
+ end
203
+
204
+ # Returns the object in the form of hash
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_hash
207
+ hash = {}
208
+ self.class.attribute_map.each_pair do |attr, param|
209
+ value = self.send(attr)
210
+ if value.nil?
211
+ is_nullable = self.class.openapi_nullable.include?(attr)
212
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
213
+ end
214
+
215
+ hash[param] = _to_hash(value)
216
+ end
217
+ hash
218
+ end
219
+
220
+ # Outputs non-array value in the form of hash
221
+ # For object, use to_hash. Otherwise, just return the value
222
+ # @param [Object] value Any valid value
223
+ # @return [Hash] Returns the value in the form of hash
224
+ def _to_hash(value)
225
+ if value.is_a?(Array)
226
+ value.compact.map { |v| _to_hash(v) }
227
+ elsif value.is_a?(Hash)
228
+ {}.tap do |hash|
229
+ value.each { |k, v| hash[k] = _to_hash(v) }
230
+ end
231
+ elsif value.respond_to? :to_hash
232
+ value.to_hash
233
+ else
234
+ value
235
+ end
236
+ end
237
+
238
+ end
239
+
240
+ end
@@ -0,0 +1,378 @@
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
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # Represents a smart contract on the blockchain
18
+ class SmartContract
19
+ # The unique identifier of the smart contract
20
+ attr_accessor :smart_contract_id
21
+
22
+ # The name of the blockchain network
23
+ attr_accessor :network_id
24
+
25
+ # The ID of the wallet that deployed the smart contract
26
+ attr_accessor :wallet_id
27
+
28
+ # The EVM address of the smart contract
29
+ attr_accessor :contract_address
30
+
31
+ # The EVM address of the account that deployed the smart contract
32
+ attr_accessor :deployer_address
33
+
34
+ attr_accessor :type
35
+
36
+ attr_accessor :options
37
+
38
+ # The JSON-encoded ABI of the contract
39
+ attr_accessor :abi
40
+
41
+ attr_accessor :transaction
42
+
43
+ class EnumAttributeValidator
44
+ attr_reader :datatype
45
+ attr_reader :allowable_values
46
+
47
+ def initialize(datatype, allowable_values)
48
+ @allowable_values = allowable_values.map do |value|
49
+ case datatype.to_s
50
+ when /Integer/i
51
+ value.to_i
52
+ when /Float/i
53
+ value.to_f
54
+ else
55
+ value
56
+ end
57
+ end
58
+ end
59
+
60
+ def valid?(value)
61
+ !value || allowable_values.include?(value)
62
+ end
63
+ end
64
+
65
+ # Attribute mapping from ruby-style variable name to JSON key.
66
+ def self.attribute_map
67
+ {
68
+ :'smart_contract_id' => :'smart_contract_id',
69
+ :'network_id' => :'network_id',
70
+ :'wallet_id' => :'wallet_id',
71
+ :'contract_address' => :'contract_address',
72
+ :'deployer_address' => :'deployer_address',
73
+ :'type' => :'type',
74
+ :'options' => :'options',
75
+ :'abi' => :'abi',
76
+ :'transaction' => :'transaction'
77
+ }
78
+ end
79
+
80
+ # Returns all the JSON keys this model knows about
81
+ def self.acceptable_attributes
82
+ attribute_map.values
83
+ end
84
+
85
+ # Attribute type mapping.
86
+ def self.openapi_types
87
+ {
88
+ :'smart_contract_id' => :'String',
89
+ :'network_id' => :'String',
90
+ :'wallet_id' => :'String',
91
+ :'contract_address' => :'String',
92
+ :'deployer_address' => :'String',
93
+ :'type' => :'SmartContractType',
94
+ :'options' => :'SmartContractOptions',
95
+ :'abi' => :'String',
96
+ :'transaction' => :'Transaction'
97
+ }
98
+ end
99
+
100
+ # List of attributes with nullable: true
101
+ def self.openapi_nullable
102
+ Set.new([
103
+ ])
104
+ end
105
+
106
+ # Initializes the object
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ def initialize(attributes = {})
109
+ if (!attributes.is_a?(Hash))
110
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::SmartContract` initialize method"
111
+ end
112
+
113
+ # check to see if the attribute exists and convert string to symbol for hash key
114
+ attributes = attributes.each_with_object({}) { |(k, v), h|
115
+ if (!self.class.attribute_map.key?(k.to_sym))
116
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::SmartContract`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
117
+ end
118
+ h[k.to_sym] = v
119
+ }
120
+
121
+ if attributes.key?(:'smart_contract_id')
122
+ self.smart_contract_id = attributes[:'smart_contract_id']
123
+ else
124
+ self.smart_contract_id = nil
125
+ end
126
+
127
+ if attributes.key?(:'network_id')
128
+ self.network_id = attributes[:'network_id']
129
+ else
130
+ self.network_id = nil
131
+ end
132
+
133
+ if attributes.key?(:'wallet_id')
134
+ self.wallet_id = attributes[:'wallet_id']
135
+ else
136
+ self.wallet_id = nil
137
+ end
138
+
139
+ if attributes.key?(:'contract_address')
140
+ self.contract_address = attributes[:'contract_address']
141
+ else
142
+ self.contract_address = nil
143
+ end
144
+
145
+ if attributes.key?(:'deployer_address')
146
+ self.deployer_address = attributes[:'deployer_address']
147
+ else
148
+ self.deployer_address = nil
149
+ end
150
+
151
+ if attributes.key?(:'type')
152
+ self.type = attributes[:'type']
153
+ else
154
+ self.type = nil
155
+ end
156
+
157
+ if attributes.key?(:'options')
158
+ self.options = attributes[:'options']
159
+ else
160
+ self.options = nil
161
+ end
162
+
163
+ if attributes.key?(:'abi')
164
+ self.abi = attributes[:'abi']
165
+ else
166
+ self.abi = nil
167
+ end
168
+
169
+ if attributes.key?(:'transaction')
170
+ self.transaction = attributes[:'transaction']
171
+ else
172
+ self.transaction = nil
173
+ end
174
+ end
175
+
176
+ # Show invalid properties with the reasons. Usually used together with valid?
177
+ # @return Array for valid properties with the reasons
178
+ def list_invalid_properties
179
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
180
+ invalid_properties = Array.new
181
+ if @smart_contract_id.nil?
182
+ invalid_properties.push('invalid value for "smart_contract_id", smart_contract_id cannot be nil.')
183
+ end
184
+
185
+ if @network_id.nil?
186
+ invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
187
+ end
188
+
189
+ if @wallet_id.nil?
190
+ invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.')
191
+ end
192
+
193
+ if @contract_address.nil?
194
+ invalid_properties.push('invalid value for "contract_address", contract_address cannot be nil.')
195
+ end
196
+
197
+ if @deployer_address.nil?
198
+ invalid_properties.push('invalid value for "deployer_address", deployer_address cannot be nil.')
199
+ end
200
+
201
+ if @type.nil?
202
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
203
+ end
204
+
205
+ if @options.nil?
206
+ invalid_properties.push('invalid value for "options", options cannot be nil.')
207
+ end
208
+
209
+ if @abi.nil?
210
+ invalid_properties.push('invalid value for "abi", abi cannot be nil.')
211
+ end
212
+
213
+ if @transaction.nil?
214
+ invalid_properties.push('invalid value for "transaction", transaction cannot be nil.')
215
+ end
216
+
217
+ invalid_properties
218
+ end
219
+
220
+ # Check to see if the all the properties in the model are valid
221
+ # @return true if the model is valid
222
+ def valid?
223
+ warn '[DEPRECATED] the `valid?` method is obsolete'
224
+ return false if @smart_contract_id.nil?
225
+ return false if @network_id.nil?
226
+ return false if @wallet_id.nil?
227
+ return false if @contract_address.nil?
228
+ return false if @deployer_address.nil?
229
+ return false if @type.nil?
230
+ return false if @options.nil?
231
+ return false if @abi.nil?
232
+ return false if @transaction.nil?
233
+ true
234
+ end
235
+
236
+ # Checks equality by comparing each attribute.
237
+ # @param [Object] Object to be compared
238
+ def ==(o)
239
+ return true if self.equal?(o)
240
+ self.class == o.class &&
241
+ smart_contract_id == o.smart_contract_id &&
242
+ network_id == o.network_id &&
243
+ wallet_id == o.wallet_id &&
244
+ contract_address == o.contract_address &&
245
+ deployer_address == o.deployer_address &&
246
+ type == o.type &&
247
+ options == o.options &&
248
+ abi == o.abi &&
249
+ transaction == o.transaction
250
+ end
251
+
252
+ # @see the `==` method
253
+ # @param [Object] Object to be compared
254
+ def eql?(o)
255
+ self == o
256
+ end
257
+
258
+ # Calculates hash code according to all attributes.
259
+ # @return [Integer] Hash code
260
+ def hash
261
+ [smart_contract_id, network_id, wallet_id, contract_address, deployer_address, type, options, abi, transaction].hash
262
+ end
263
+
264
+ # Builds the object from hash
265
+ # @param [Hash] attributes Model attributes in the form of hash
266
+ # @return [Object] Returns the model itself
267
+ def self.build_from_hash(attributes)
268
+ return nil unless attributes.is_a?(Hash)
269
+ attributes = attributes.transform_keys(&:to_sym)
270
+ transformed_hash = {}
271
+ openapi_types.each_pair do |key, type|
272
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
273
+ transformed_hash["#{key}"] = nil
274
+ elsif type =~ /\AArray<(.*)>/i
275
+ # check to ensure the input is an array given that the attribute
276
+ # is documented as an array but the input is not
277
+ if attributes[attribute_map[key]].is_a?(Array)
278
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
279
+ end
280
+ elsif !attributes[attribute_map[key]].nil?
281
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
282
+ end
283
+ end
284
+ new(transformed_hash)
285
+ end
286
+
287
+ # Deserializes the data based on type
288
+ # @param string type Data type
289
+ # @param string value Value to be deserialized
290
+ # @return [Object] Deserialized data
291
+ def self._deserialize(type, value)
292
+ case type.to_sym
293
+ when :Time
294
+ Time.parse(value)
295
+ when :Date
296
+ Date.parse(value)
297
+ when :String
298
+ value.to_s
299
+ when :Integer
300
+ value.to_i
301
+ when :Float
302
+ value.to_f
303
+ when :Boolean
304
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
305
+ true
306
+ else
307
+ false
308
+ end
309
+ when :Object
310
+ # generic object (usually a Hash), return directly
311
+ value
312
+ when /\AArray<(?<inner_type>.+)>\z/
313
+ inner_type = Regexp.last_match[:inner_type]
314
+ value.map { |v| _deserialize(inner_type, v) }
315
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
316
+ k_type = Regexp.last_match[:k_type]
317
+ v_type = Regexp.last_match[:v_type]
318
+ {}.tap do |hash|
319
+ value.each do |k, v|
320
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
321
+ end
322
+ end
323
+ else # model
324
+ # models (e.g. Pet) or oneOf
325
+ klass = Coinbase::Client.const_get(type)
326
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
327
+ end
328
+ end
329
+
330
+ # Returns the string representation of the object
331
+ # @return [String] String presentation of the object
332
+ def to_s
333
+ to_hash.to_s
334
+ end
335
+
336
+ # to_body is an alias to to_hash (backward compatibility)
337
+ # @return [Hash] Returns the object in the form of hash
338
+ def to_body
339
+ to_hash
340
+ end
341
+
342
+ # Returns the object in the form of hash
343
+ # @return [Hash] Returns the object in the form of hash
344
+ def to_hash
345
+ hash = {}
346
+ self.class.attribute_map.each_pair do |attr, param|
347
+ value = self.send(attr)
348
+ if value.nil?
349
+ is_nullable = self.class.openapi_nullable.include?(attr)
350
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
351
+ end
352
+
353
+ hash[param] = _to_hash(value)
354
+ end
355
+ hash
356
+ end
357
+
358
+ # Outputs non-array value in the form of hash
359
+ # For object, use to_hash. Otherwise, just return the value
360
+ # @param [Object] value Any valid value
361
+ # @return [Hash] Returns the value in the form of hash
362
+ def _to_hash(value)
363
+ if value.is_a?(Array)
364
+ value.compact.map { |v| _to_hash(v) }
365
+ elsif value.is_a?(Hash)
366
+ {}.tap do |hash|
367
+ value.each { |k, v| hash[k] = _to_hash(v) }
368
+ end
369
+ elsif value.respond_to? :to_hash
370
+ value.to_hash
371
+ else
372
+ value
373
+ end
374
+ end
375
+
376
+ end
377
+
378
+ end