coinbase-sdk 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +35 -2
  3. data/lib/coinbase/address.rb +5 -1
  4. data/lib/coinbase/client/api/addresses_api.rb +10 -10
  5. data/lib/coinbase/client/api/assets_api.rb +2 -2
  6. data/lib/coinbase/client/api/balance_history_api.rb +107 -0
  7. data/lib/coinbase/client/api/contract_events_api.rb +4 -4
  8. data/lib/coinbase/client/api/contract_invocations_api.rb +5 -5
  9. data/lib/coinbase/client/api/external_addresses_api.rb +5 -90
  10. data/lib/coinbase/client/api/networks_api.rb +2 -2
  11. data/lib/coinbase/client/api/server_signers_api.rb +7 -7
  12. data/lib/coinbase/client/api/smart_contracts_api.rb +332 -0
  13. data/lib/coinbase/client/api/stake_api.rb +6 -14
  14. data/lib/coinbase/client/api/trades_api.rb +5 -5
  15. data/lib/coinbase/client/api/transfers_api.rb +5 -5
  16. data/lib/coinbase/client/api/users_api.rb +2 -2
  17. data/lib/coinbase/client/api/validators_api.rb +3 -3
  18. data/lib/coinbase/client/api/wallet_stake_api.rb +4 -4
  19. data/lib/coinbase/client/api/wallets_api.rb +6 -6
  20. data/lib/coinbase/client/api/webhooks_api.rb +5 -5
  21. data/lib/coinbase/client/api_client.rb +30 -24
  22. data/lib/coinbase/client/api_error.rb +1 -1
  23. data/lib/coinbase/client/configuration.rb +1 -1
  24. data/lib/coinbase/client/models/address.rb +1 -1
  25. data/lib/coinbase/client/models/address_balance_list.rb +1 -1
  26. data/lib/coinbase/client/models/address_historical_balance_list.rb +1 -1
  27. data/lib/coinbase/client/models/address_list.rb +1 -1
  28. data/lib/coinbase/client/models/address_transaction_list.rb +1 -1
  29. data/lib/coinbase/client/models/asset.rb +1 -1
  30. data/lib/coinbase/client/models/balance.rb +1 -1
  31. data/lib/coinbase/client/models/broadcast_contract_invocation_request.rb +1 -1
  32. data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +1 -1
  33. data/lib/coinbase/client/models/broadcast_trade_request.rb +1 -1
  34. data/lib/coinbase/client/models/broadcast_transfer_request.rb +1 -1
  35. data/lib/coinbase/client/models/build_staking_operation_request.rb +1 -1
  36. data/lib/coinbase/client/models/contract_event.rb +1 -1
  37. data/lib/coinbase/client/models/contract_event_list.rb +1 -1
  38. data/lib/coinbase/client/models/contract_invocation.rb +19 -2
  39. data/lib/coinbase/client/models/contract_invocation_list.rb +1 -1
  40. data/lib/coinbase/client/models/create_address_request.rb +1 -1
  41. data/lib/coinbase/client/models/create_contract_invocation_request.rb +15 -5
  42. data/lib/coinbase/client/models/create_payload_signature_request.rb +1 -1
  43. data/lib/coinbase/client/models/create_server_signer_request.rb +1 -1
  44. data/lib/coinbase/client/models/create_smart_contract_request.rb +259 -0
  45. data/lib/coinbase/client/models/create_staking_operation_request.rb +1 -1
  46. data/lib/coinbase/client/models/create_trade_request.rb +1 -1
  47. data/lib/coinbase/client/models/create_transfer_request.rb +2 -2
  48. data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
  49. data/lib/coinbase/client/models/create_wallet_request_wallet.rb +1 -1
  50. data/lib/coinbase/client/models/create_webhook_request.rb +11 -9
  51. data/lib/coinbase/client/models/deploy_smart_contract_request.rb +222 -0
  52. data/lib/coinbase/client/models/erc20_transfer_event.rb +336 -0
  53. data/lib/coinbase/client/models/erc721_transfer_event.rb +336 -0
  54. data/lib/coinbase/client/models/error.rb +15 -5
  55. data/lib/coinbase/client/models/ethereum_transaction.rb +1 -1
  56. data/lib/coinbase/client/models/ethereum_transaction_access.rb +1 -1
  57. data/lib/coinbase/client/models/ethereum_transaction_access_list.rb +1 -1
  58. data/lib/coinbase/client/models/ethereum_transaction_flattened_trace.rb +1 -1
  59. data/lib/coinbase/client/models/ethereum_validator_metadata.rb +1 -1
  60. data/lib/coinbase/client/models/faucet_transaction.rb +1 -1
  61. data/lib/coinbase/client/models/feature_set.rb +1 -1
  62. data/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +1 -1
  63. data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +1 -1
  64. data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +1 -1
  65. data/lib/coinbase/client/models/get_staking_context_request.rb +1 -1
  66. data/lib/coinbase/client/models/historical_balance.rb +1 -1
  67. data/lib/coinbase/client/models/network.rb +1 -1
  68. data/lib/coinbase/client/models/network_identifier.rb +3 -2
  69. data/lib/coinbase/client/models/nft_contract_options.rb +240 -0
  70. data/lib/coinbase/client/models/payload_signature.rb +1 -1
  71. data/lib/coinbase/client/models/payload_signature_list.rb +1 -1
  72. data/lib/coinbase/client/models/seed_creation_event.rb +1 -1
  73. data/lib/coinbase/client/models/seed_creation_event_result.rb +1 -1
  74. data/lib/coinbase/client/models/server_signer.rb +1 -1
  75. data/lib/coinbase/client/models/server_signer_event.rb +1 -1
  76. data/lib/coinbase/client/models/server_signer_event_event.rb +1 -1
  77. data/lib/coinbase/client/models/server_signer_event_list.rb +1 -1
  78. data/lib/coinbase/client/models/server_signer_list.rb +1 -1
  79. data/lib/coinbase/client/models/signature_creation_event.rb +1 -1
  80. data/lib/coinbase/client/models/signature_creation_event_result.rb +1 -1
  81. data/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb +1 -1
  82. data/lib/coinbase/client/models/smart_contract.rb +378 -0
  83. data/lib/coinbase/client/models/smart_contract_list.rb +257 -0
  84. data/lib/coinbase/client/models/smart_contract_options.rb +106 -0
  85. data/lib/coinbase/client/models/smart_contract_type.rb +41 -0
  86. data/lib/coinbase/client/models/sponsored_send.rb +1 -1
  87. data/lib/coinbase/client/models/staking_balance.rb +3 -3
  88. data/lib/coinbase/client/models/staking_context.rb +1 -1
  89. data/lib/coinbase/client/models/staking_context_context.rb +1 -1
  90. data/lib/coinbase/client/models/staking_operation.rb +1 -1
  91. data/lib/coinbase/client/models/staking_operation_metadata.rb +1 -1
  92. data/lib/coinbase/client/models/staking_reward.rb +3 -3
  93. data/lib/coinbase/client/models/staking_reward_format.rb +1 -1
  94. data/lib/coinbase/client/models/staking_reward_usd_value.rb +1 -1
  95. data/lib/coinbase/client/models/token_contract_options.rb +257 -0
  96. data/lib/coinbase/client/models/trade.rb +1 -1
  97. data/lib/coinbase/client/models/trade_list.rb +1 -1
  98. data/lib/coinbase/client/models/transaction.rb +1 -1
  99. data/lib/coinbase/client/models/transaction_content.rb +1 -1
  100. data/lib/coinbase/client/models/transaction_type.rb +1 -1
  101. data/lib/coinbase/client/models/transfer.rb +1 -1
  102. data/lib/coinbase/client/models/transfer_list.rb +1 -1
  103. data/lib/coinbase/client/models/update_webhook_request.rb +11 -9
  104. data/lib/coinbase/client/models/user.rb +1 -1
  105. data/lib/coinbase/client/models/validator.rb +1 -1
  106. data/lib/coinbase/client/models/validator_details.rb +1 -1
  107. data/lib/coinbase/client/models/validator_list.rb +1 -1
  108. data/lib/coinbase/client/models/validator_status.rb +1 -1
  109. data/lib/coinbase/client/models/wallet.rb +1 -1
  110. data/lib/coinbase/client/models/wallet_list.rb +1 -1
  111. data/lib/coinbase/client/models/webhook.rb +11 -2
  112. data/lib/coinbase/client/models/webhook_event_filter.rb +4 -4
  113. data/lib/coinbase/client/models/webhook_event_type.rb +3 -2
  114. data/lib/coinbase/client/models/webhook_event_type_filter.rb +105 -0
  115. data/lib/coinbase/client/models/webhook_list.rb +1 -1
  116. data/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +228 -0
  117. data/lib/coinbase/client/version.rb +1 -1
  118. data/lib/coinbase/client.rb +15 -1
  119. data/lib/coinbase/contract_invocation.rb +34 -10
  120. data/lib/coinbase/smart_contract.rb +216 -45
  121. data/lib/coinbase/transaction.rb +3 -0
  122. data/lib/coinbase/transfer.rb +1 -1
  123. data/lib/coinbase/version.rb +1 -1
  124. data/lib/coinbase/wallet.rb +11 -2
  125. metadata +16 -2
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.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
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.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
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.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
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.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
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.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
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.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
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.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
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -24,6 +24,8 @@ module Coinbase::Client
24
24
 
25
25
  attr_accessor :event_type
26
26
 
27
+ attr_accessor :event_type_filter
28
+
27
29
  # Webhook will monitor all events that matches any one of the event filters.
28
30
  attr_accessor :event_filters
29
31
 
@@ -67,6 +69,7 @@ module Coinbase::Client
67
69
  :'id' => :'id',
68
70
  :'network_id' => :'network_id',
69
71
  :'event_type' => :'event_type',
72
+ :'event_type_filter' => :'event_type_filter',
70
73
  :'event_filters' => :'event_filters',
71
74
  :'notification_uri' => :'notification_uri',
72
75
  :'created_at' => :'created_at',
@@ -86,6 +89,7 @@ module Coinbase::Client
86
89
  :'id' => :'String',
87
90
  :'network_id' => :'String',
88
91
  :'event_type' => :'WebhookEventType',
92
+ :'event_type_filter' => :'WebhookEventTypeFilter',
89
93
  :'event_filters' => :'Array<WebhookEventFilter>',
90
94
  :'notification_uri' => :'String',
91
95
  :'created_at' => :'Time',
@@ -127,6 +131,10 @@ module Coinbase::Client
127
131
  self.event_type = attributes[:'event_type']
128
132
  end
129
133
 
134
+ if attributes.key?(:'event_type_filter')
135
+ self.event_type_filter = attributes[:'event_type_filter']
136
+ end
137
+
130
138
  if attributes.key?(:'event_filters')
131
139
  if (value = attributes[:'event_filters']).is_a?(Array)
132
140
  self.event_filters = value
@@ -173,6 +181,7 @@ module Coinbase::Client
173
181
  id == o.id &&
174
182
  network_id == o.network_id &&
175
183
  event_type == o.event_type &&
184
+ event_type_filter == o.event_type_filter &&
176
185
  event_filters == o.event_filters &&
177
186
  notification_uri == o.notification_uri &&
178
187
  created_at == o.created_at &&
@@ -189,7 +198,7 @@ module Coinbase::Client
189
198
  # Calculates hash code according to all attributes.
190
199
  # @return [Integer] Hash code
191
200
  def hash
192
- [id, network_id, event_type, event_filters, notification_uri, created_at, updated_at, signature_header].hash
201
+ [id, network_id, event_type, event_type_filter, event_filters, notification_uri, created_at, updated_at, signature_header].hash
193
202
  end
194
203
 
195
204
  # Builds the object from hash
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -16,13 +16,13 @@ require 'time'
16
16
  module Coinbase::Client
17
17
  # The event_filter parameter specifies the criteria to filter events from the blockchain. It allows filtering events by contract address, sender address and receiver address. For a single event filter, not all of the properties need to be presented.
18
18
  class WebhookEventFilter
19
- # The onchain contract address of the token being transferred.
19
+ # The onchain contract address of the token for which the events should be tracked.
20
20
  attr_accessor :contract_address
21
21
 
22
- # The onchain address of the sender.
22
+ # The onchain address of the sender. Set this filter to track all transfer events originating from your address.
23
23
  attr_accessor :from_address
24
24
 
25
- # The onchain address of the receiver.
25
+ # The onchain address of the receiver. Set this filter to track all transfer events sent to your address.
26
26
  attr_accessor :to_address
27
27
 
28
28
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -18,10 +18,11 @@ module Coinbase::Client
18
18
  UNSPECIFIED = "unspecified".freeze
19
19
  ERC20_TRANSFER = "erc20_transfer".freeze
20
20
  ERC721_TRANSFER = "erc721_transfer".freeze
21
+ WALLET_ACTIVITY = "wallet_activity".freeze
21
22
  UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
22
23
 
23
24
  def self.all_vars
24
- @all_vars ||= [UNSPECIFIED, ERC20_TRANSFER, ERC721_TRANSFER, UNKNOWN_DEFAULT_OPEN_API].freeze
25
+ @all_vars ||= [UNSPECIFIED, ERC20_TRANSFER, ERC721_TRANSFER, WALLET_ACTIVITY, UNKNOWN_DEFAULT_OPEN_API].freeze
25
26
  end
26
27
 
27
28
  # Builds the enum from string
@@ -0,0 +1,105 @@
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
+ # The event_type_filter parameter specifies the criteria to filter events based on event type.
18
+ module WebhookEventTypeFilter
19
+ class << self
20
+ # List of class defined in oneOf (OpenAPI v3)
21
+ def openapi_one_of
22
+ [
23
+ :'WebhookWalletActivityFilter'
24
+ ]
25
+ end
26
+
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of oneOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - We do not attempt to check whether exactly one item matches.
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_one_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ typed_data = find_and_cast_into_type(klass, data)
42
+ return typed_data if typed_data
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_one_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.parse(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = Coinbase::Client.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+
105
+ end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -0,0 +1,228 @@
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
+ # Filter for wallet activity events. This filter allows the client to specify one or more wallet addresses to monitor for activities such as transactions, transfers, or other types of events that are associated with the specified addresses.
18
+ class WebhookWalletActivityFilter
19
+ # A list of wallet addresses to filter on.
20
+ attr_accessor :addresses
21
+
22
+ # The ID of the wallet that owns the webhook.
23
+ attr_accessor :wallet_id
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'addresses' => :'addresses',
29
+ :'wallet_id' => :'wallet_id'
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
+ :'addresses' => :'Array<String>',
42
+ :'wallet_id' => :'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::WebhookWalletActivityFilter` 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::WebhookWalletActivityFilter`. 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?(:'addresses')
68
+ if (value = attributes[:'addresses']).is_a?(Array)
69
+ self.addresses = value
70
+ end
71
+ end
72
+
73
+ if attributes.key?(:'wallet_id')
74
+ self.wallet_id = attributes[:'wallet_id']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
82
+ invalid_properties = Array.new
83
+ invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ warn '[DEPRECATED] the `valid?` method is obsolete'
90
+ true
91
+ end
92
+
93
+ # Checks equality by comparing each attribute.
94
+ # @param [Object] Object to be compared
95
+ def ==(o)
96
+ return true if self.equal?(o)
97
+ self.class == o.class &&
98
+ addresses == o.addresses &&
99
+ wallet_id == o.wallet_id
100
+ end
101
+
102
+ # @see the `==` method
103
+ # @param [Object] Object to be compared
104
+ def eql?(o)
105
+ self == o
106
+ end
107
+
108
+ # Calculates hash code according to all attributes.
109
+ # @return [Integer] Hash code
110
+ def hash
111
+ [addresses, wallet_id].hash
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def self.build_from_hash(attributes)
118
+ return nil unless attributes.is_a?(Hash)
119
+ attributes = attributes.transform_keys(&:to_sym)
120
+ transformed_hash = {}
121
+ openapi_types.each_pair do |key, type|
122
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
123
+ transformed_hash["#{key}"] = nil
124
+ elsif type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[attribute_map[key]].is_a?(Array)
128
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
129
+ end
130
+ elsif !attributes[attribute_map[key]].nil?
131
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
132
+ end
133
+ end
134
+ new(transformed_hash)
135
+ end
136
+
137
+ # Deserializes the data based on type
138
+ # @param string type Data type
139
+ # @param string value Value to be deserialized
140
+ # @return [Object] Deserialized data
141
+ def self._deserialize(type, value)
142
+ case type.to_sym
143
+ when :Time
144
+ Time.parse(value)
145
+ when :Date
146
+ Date.parse(value)
147
+ when :String
148
+ value.to_s
149
+ when :Integer
150
+ value.to_i
151
+ when :Float
152
+ value.to_f
153
+ when :Boolean
154
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
155
+ true
156
+ else
157
+ false
158
+ end
159
+ when :Object
160
+ # generic object (usually a Hash), return directly
161
+ value
162
+ when /\AArray<(?<inner_type>.+)>\z/
163
+ inner_type = Regexp.last_match[:inner_type]
164
+ value.map { |v| _deserialize(inner_type, v) }
165
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
166
+ k_type = Regexp.last_match[:k_type]
167
+ v_type = Regexp.last_match[:v_type]
168
+ {}.tap do |hash|
169
+ value.each do |k, v|
170
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
+ end
172
+ end
173
+ else # model
174
+ # models (e.g. Pet) or oneOf
175
+ klass = Coinbase::Client.const_get(type)
176
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
177
+ end
178
+ end
179
+
180
+ # Returns the string representation of the object
181
+ # @return [String] String presentation of the object
182
+ def to_s
183
+ to_hash.to_s
184
+ end
185
+
186
+ # to_body is an alias to to_hash (backward compatibility)
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_body
189
+ to_hash
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = self.send(attr)
198
+ if value.nil?
199
+ is_nullable = self.class.openapi_nullable.include?(attr)
200
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
201
+ end
202
+
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map { |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+
226
+ end
227
+
228
+ end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.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
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -37,12 +37,16 @@ Coinbase::Client.autoload :CreateAddressRequest, 'coinbase/client/models/create_
37
37
  Coinbase::Client.autoload :CreateContractInvocationRequest, 'coinbase/client/models/create_contract_invocation_request'
38
38
  Coinbase::Client.autoload :CreatePayloadSignatureRequest, 'coinbase/client/models/create_payload_signature_request'
39
39
  Coinbase::Client.autoload :CreateServerSignerRequest, 'coinbase/client/models/create_server_signer_request'
40
+ Coinbase::Client.autoload :CreateSmartContractRequest, 'coinbase/client/models/create_smart_contract_request'
40
41
  Coinbase::Client.autoload :CreateStakingOperationRequest, 'coinbase/client/models/create_staking_operation_request'
41
42
  Coinbase::Client.autoload :CreateTradeRequest, 'coinbase/client/models/create_trade_request'
42
43
  Coinbase::Client.autoload :CreateTransferRequest, 'coinbase/client/models/create_transfer_request'
43
44
  Coinbase::Client.autoload :CreateWalletRequest, 'coinbase/client/models/create_wallet_request'
44
45
  Coinbase::Client.autoload :CreateWalletRequestWallet, 'coinbase/client/models/create_wallet_request_wallet'
45
46
  Coinbase::Client.autoload :CreateWebhookRequest, 'coinbase/client/models/create_webhook_request'
47
+ Coinbase::Client.autoload :DeploySmartContractRequest, 'coinbase/client/models/deploy_smart_contract_request'
48
+ Coinbase::Client.autoload :ERC20TransferEvent, 'coinbase/client/models/erc20_transfer_event'
49
+ Coinbase::Client.autoload :ERC721TransferEvent, 'coinbase/client/models/erc721_transfer_event'
46
50
  Coinbase::Client.autoload :Error, 'coinbase/client/models/error'
47
51
  Coinbase::Client.autoload :EthereumTransaction, 'coinbase/client/models/ethereum_transaction'
48
52
  Coinbase::Client.autoload :EthereumTransactionAccess, 'coinbase/client/models/ethereum_transaction_access'
@@ -56,6 +60,7 @@ Coinbase::Client.autoload :FetchStakingRewards200Response, 'coinbase/client/mode
56
60
  Coinbase::Client.autoload :FetchStakingRewardsRequest, 'coinbase/client/models/fetch_staking_rewards_request'
57
61
  Coinbase::Client.autoload :GetStakingContextRequest, 'coinbase/client/models/get_staking_context_request'
58
62
  Coinbase::Client.autoload :HistoricalBalance, 'coinbase/client/models/historical_balance'
63
+ Coinbase::Client.autoload :NFTContractOptions, 'coinbase/client/models/nft_contract_options'
59
64
  Coinbase::Client.autoload :Network, 'coinbase/client/models/network'
60
65
  Coinbase::Client.autoload :NetworkIdentifier, 'coinbase/client/models/network_identifier'
61
66
  Coinbase::Client.autoload :PayloadSignature, 'coinbase/client/models/payload_signature'
@@ -70,6 +75,10 @@ Coinbase::Client.autoload :ServerSignerList, 'coinbase/client/models/server_sign
70
75
  Coinbase::Client.autoload :SignatureCreationEvent, 'coinbase/client/models/signature_creation_event'
71
76
  Coinbase::Client.autoload :SignatureCreationEventResult, 'coinbase/client/models/signature_creation_event_result'
72
77
  Coinbase::Client.autoload :SignedVoluntaryExitMessageMetadata, 'coinbase/client/models/signed_voluntary_exit_message_metadata'
78
+ Coinbase::Client.autoload :SmartContract, 'coinbase/client/models/smart_contract'
79
+ Coinbase::Client.autoload :SmartContractList, 'coinbase/client/models/smart_contract_list'
80
+ Coinbase::Client.autoload :SmartContractOptions, 'coinbase/client/models/smart_contract_options'
81
+ Coinbase::Client.autoload :SmartContractType, 'coinbase/client/models/smart_contract_type'
73
82
  Coinbase::Client.autoload :SponsoredSend, 'coinbase/client/models/sponsored_send'
74
83
  Coinbase::Client.autoload :StakingBalance, 'coinbase/client/models/staking_balance'
75
84
  Coinbase::Client.autoload :StakingContext, 'coinbase/client/models/staking_context'
@@ -79,6 +88,7 @@ Coinbase::Client.autoload :StakingOperationMetadata, 'coinbase/client/models/sta
79
88
  Coinbase::Client.autoload :StakingReward, 'coinbase/client/models/staking_reward'
80
89
  Coinbase::Client.autoload :StakingRewardFormat, 'coinbase/client/models/staking_reward_format'
81
90
  Coinbase::Client.autoload :StakingRewardUSDValue, 'coinbase/client/models/staking_reward_usd_value'
91
+ Coinbase::Client.autoload :TokenContractOptions, 'coinbase/client/models/token_contract_options'
82
92
  Coinbase::Client.autoload :Trade, 'coinbase/client/models/trade'
83
93
  Coinbase::Client.autoload :TradeList, 'coinbase/client/models/trade_list'
84
94
  Coinbase::Client.autoload :Transaction, 'coinbase/client/models/transaction'
@@ -97,16 +107,20 @@ Coinbase::Client.autoload :WalletList, 'coinbase/client/models/wallet_list'
97
107
  Coinbase::Client.autoload :Webhook, 'coinbase/client/models/webhook'
98
108
  Coinbase::Client.autoload :WebhookEventFilter, 'coinbase/client/models/webhook_event_filter'
99
109
  Coinbase::Client.autoload :WebhookEventType, 'coinbase/client/models/webhook_event_type'
110
+ Coinbase::Client.autoload :WebhookEventTypeFilter, 'coinbase/client/models/webhook_event_type_filter'
100
111
  Coinbase::Client.autoload :WebhookList, 'coinbase/client/models/webhook_list'
112
+ Coinbase::Client.autoload :WebhookWalletActivityFilter, 'coinbase/client/models/webhook_wallet_activity_filter'
101
113
 
102
114
  # APIs
103
115
  Coinbase::Client.autoload :AddressesApi, 'coinbase/client/api/addresses_api'
104
116
  Coinbase::Client.autoload :AssetsApi, 'coinbase/client/api/assets_api'
117
+ Coinbase::Client.autoload :BalanceHistoryApi, 'coinbase/client/api/balance_history_api'
105
118
  Coinbase::Client.autoload :ContractEventsApi, 'coinbase/client/api/contract_events_api'
106
119
  Coinbase::Client.autoload :ContractInvocationsApi, 'coinbase/client/api/contract_invocations_api'
107
120
  Coinbase::Client.autoload :ExternalAddressesApi, 'coinbase/client/api/external_addresses_api'
108
121
  Coinbase::Client.autoload :NetworksApi, 'coinbase/client/api/networks_api'
109
122
  Coinbase::Client.autoload :ServerSignersApi, 'coinbase/client/api/server_signers_api'
123
+ Coinbase::Client.autoload :SmartContractsApi, 'coinbase/client/api/smart_contracts_api'
110
124
  Coinbase::Client.autoload :StakeApi, 'coinbase/client/api/stake_api'
111
125
  Coinbase::Client.autoload :TradesApi, 'coinbase/client/api/trades_api'
112
126
  Coinbase::Client.autoload :TransfersApi, 'coinbase/client/api/transfers_api'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bigdecimal'
4
+
3
5
  module Coinbase
4
6
  # A representation of a Contract Invocation.
5
7
  class ContractInvocation
@@ -10,6 +12,11 @@ module Coinbase
10
12
  # @param contract_address [String] The contract address
11
13
  # @param abi [Array<Hash>] The contract ABI
12
14
  # @param method [String] The contract method
15
+ # @param amount [Integer, Float, BigDecimal] The amount of the native Asset
16
+ # to send to a payable contract method.
17
+ # @param asset_id [Symbol] The ID of the Asset to send to a payable contract method.
18
+ # The Asset must be a denomination of the native Asset. For Ethereum, :eth, :gwei, and :wei are supported.
19
+ # @param network [Coinbase::Network, Symbol] The Network or Network ID of the Asset
13
20
  # @param args [Hash] The arguments to pass to the contract method.
14
21
  # The keys should be the argument names, and the values should be the argument values.
15
22
  # @return [ContractInvocation] The new Contract Invocation object
@@ -18,19 +25,30 @@ module Coinbase
18
25
  address_id:,
19
26
  wallet_id:,
20
27
  contract_address:,
21
- abi:,
22
28
  method:,
23
- args: {}
29
+ network:,
30
+ args: {},
31
+ amount: nil,
32
+ abi: nil,
33
+ asset_id: nil
24
34
  )
35
+ req = {
36
+ method: method,
37
+ args: args.to_json,
38
+ contract_address: contract_address
39
+ }
40
+
41
+ req[:abi] = abi.to_json unless abi.nil?
42
+
43
+ # For payable contract invocations, convert the amount to atomic units of specified asset.
44
+ if amount && asset_id && network
45
+ asset = Coinbase::Asset.fetch(network, asset_id)
46
+
47
+ req[:amount] = asset.to_atomic_amount(amount).to_i.to_s
48
+ end
49
+
25
50
  model = Coinbase.call_api do
26
- contract_invocation_api.create_contract_invocation(
27
- wallet_id,
28
- address_id,
29
- contract_address: contract_address,
30
- abi: abi.to_json,
31
- method: method,
32
- args: args.to_json
33
- )
51
+ contract_invocation_api.create_contract_invocation(wallet_id, address_id, **req)
34
52
  end
35
53
 
36
54
  new(model)
@@ -121,6 +139,12 @@ module Coinbase
121
139
  JSON.parse(@model.args).transform_keys(&:to_sym)
122
140
  end
123
141
 
142
+ # Returns the amount of the native asset sent to a payable contract method, if applicable.
143
+ # @return [BigDecimal] The amount in atomic units of the native asset
144
+ def amount
145
+ BigDecimal(@model.amount)
146
+ end
147
+
124
148
  # Returns the transaction.
125
149
  # @return [Coinbase::Transaction] The Transfer transaction
126
150
  def transaction