coinbase-sdk 0.10.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +28 -0
  3. data/lib/coinbase/address.rb +22 -3
  4. data/lib/coinbase/address_reputation.rb +67 -0
  5. data/lib/coinbase/balance.rb +1 -1
  6. data/lib/coinbase/client/api/addresses_api.rb +10 -10
  7. data/lib/coinbase/client/api/assets_api.rb +2 -2
  8. data/lib/coinbase/client/api/balance_history_api.rb +2 -2
  9. data/lib/coinbase/client/api/contract_events_api.rb +2 -2
  10. data/lib/coinbase/client/api/contract_invocations_api.rb +5 -5
  11. data/lib/coinbase/client/api/external_addresses_api.rb +246 -5
  12. data/lib/coinbase/client/api/fund_api.rb +5 -5
  13. data/lib/coinbase/client/api/{wallet_stake_api.rb → mpc_wallet_stake_api.rb} +24 -24
  14. data/lib/coinbase/client/api/networks_api.rb +2 -2
  15. data/lib/coinbase/client/api/onchain_identity_api.rb +2 -2
  16. data/lib/coinbase/client/api/reputation_api.rb +91 -0
  17. data/lib/coinbase/client/api/server_signers_api.rb +7 -7
  18. data/lib/coinbase/client/api/smart_contracts_api.rb +169 -26
  19. data/lib/coinbase/client/api/stake_api.rb +163 -6
  20. data/lib/coinbase/client/api/trades_api.rb +5 -5
  21. data/lib/coinbase/client/api/transaction_history_api.rb +2 -2
  22. data/lib/coinbase/client/api/transfers_api.rb +14 -14
  23. data/lib/coinbase/client/api/users_api.rb +1 -1
  24. data/lib/coinbase/client/api/wallets_api.rb +6 -6
  25. data/lib/coinbase/client/api/webhooks_api.rb +6 -6
  26. data/lib/coinbase/client/api_client.rb +1 -1
  27. data/lib/coinbase/client/api_error.rb +1 -1
  28. data/lib/coinbase/client/configuration.rb +15 -1
  29. data/lib/coinbase/client/models/address.rb +1 -1
  30. data/lib/coinbase/client/models/address_balance_list.rb +1 -1
  31. data/lib/coinbase/client/models/address_historical_balance_list.rb +1 -1
  32. data/lib/coinbase/client/models/address_list.rb +1 -1
  33. data/lib/coinbase/client/models/address_reputation.rb +239 -0
  34. data/lib/coinbase/client/models/address_reputation_metadata.rb +376 -0
  35. data/lib/coinbase/client/models/address_transaction_list.rb +1 -1
  36. data/lib/coinbase/client/models/asset.rb +1 -1
  37. data/lib/coinbase/client/models/balance.rb +1 -1
  38. data/lib/coinbase/client/models/broadcast_contract_invocation_request.rb +1 -1
  39. data/lib/coinbase/client/models/{broadcast_transfer_request.rb → broadcast_external_transfer_request.rb} +4 -4
  40. data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +1 -1
  41. data/lib/coinbase/client/models/broadcast_trade_request.rb +1 -1
  42. data/lib/coinbase/client/models/build_staking_operation_request.rb +2 -1
  43. data/lib/coinbase/client/models/contract_event.rb +1 -1
  44. data/lib/coinbase/client/models/contract_event_list.rb +1 -1
  45. data/lib/coinbase/client/models/contract_invocation.rb +1 -1
  46. data/lib/coinbase/client/models/contract_invocation_list.rb +1 -1
  47. data/lib/coinbase/client/models/create_address_request.rb +1 -1
  48. data/lib/coinbase/client/models/create_contract_invocation_request.rb +1 -1
  49. data/lib/coinbase/client/models/create_external_transfer_request.rb +273 -0
  50. data/lib/coinbase/client/models/create_fund_operation_request.rb +2 -2
  51. data/lib/coinbase/client/models/create_fund_quote_request.rb +2 -2
  52. data/lib/coinbase/client/models/create_payload_signature_request.rb +1 -1
  53. data/lib/coinbase/client/models/create_server_signer_request.rb +1 -1
  54. data/lib/coinbase/client/models/create_smart_contract_request.rb +1 -1
  55. data/lib/coinbase/client/models/create_staking_operation_request.rb +2 -1
  56. data/lib/coinbase/client/models/create_trade_request.rb +1 -1
  57. data/lib/coinbase/client/models/create_transfer_request.rb +2 -2
  58. data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
  59. data/lib/coinbase/client/models/create_wallet_request_wallet.rb +1 -1
  60. data/lib/coinbase/client/models/create_wallet_webhook_request.rb +1 -1
  61. data/lib/coinbase/client/models/create_webhook_request.rb +1 -1
  62. data/lib/coinbase/client/models/crypto_amount.rb +1 -1
  63. data/lib/coinbase/client/models/deploy_smart_contract_request.rb +1 -1
  64. data/lib/coinbase/client/models/erc20_transfer_event.rb +1 -1
  65. data/lib/coinbase/client/models/erc721_transfer_event.rb +1 -1
  66. data/lib/coinbase/client/models/error.rb +1 -1
  67. data/lib/coinbase/client/models/ethereum_token_transfer.rb +1 -1
  68. data/lib/coinbase/client/models/ethereum_transaction.rb +15 -5
  69. data/lib/coinbase/client/models/ethereum_transaction_access.rb +1 -1
  70. data/lib/coinbase/client/models/ethereum_transaction_access_list.rb +1 -1
  71. data/lib/coinbase/client/models/ethereum_transaction_flattened_trace.rb +1 -1
  72. data/lib/coinbase/client/models/ethereum_validator_metadata.rb +1 -1
  73. data/lib/coinbase/client/models/faucet_transaction.rb +1 -1
  74. data/lib/coinbase/client/models/feature_set.rb +1 -1
  75. data/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +1 -1
  76. data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +1 -1
  77. data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +1 -1
  78. data/lib/coinbase/client/models/fiat_amount.rb +1 -1
  79. data/lib/coinbase/client/models/fund_operation.rb +1 -1
  80. data/lib/coinbase/client/models/fund_operation_fees.rb +1 -1
  81. data/lib/coinbase/client/models/fund_operation_list.rb +1 -1
  82. data/lib/coinbase/client/models/fund_quote.rb +1 -1
  83. data/lib/coinbase/client/models/get_staking_context_request.rb +2 -1
  84. data/lib/coinbase/client/models/historical_balance.rb +1 -1
  85. data/lib/coinbase/client/models/multi_token_contract_options.rb +1 -1
  86. data/lib/coinbase/client/models/network.rb +1 -1
  87. data/lib/coinbase/client/models/network_identifier.rb +1 -1
  88. data/lib/coinbase/client/models/nft_contract_options.rb +1 -1
  89. data/lib/coinbase/client/models/onchain_name.rb +1 -1
  90. data/lib/coinbase/client/models/onchain_name_list.rb +1 -1
  91. data/lib/coinbase/client/models/payload_signature.rb +1 -1
  92. data/lib/coinbase/client/models/payload_signature_list.rb +1 -1
  93. data/lib/coinbase/client/models/read_contract_request.rb +1 -1
  94. data/lib/coinbase/client/models/register_smart_contract_request.rb +252 -0
  95. data/lib/coinbase/client/models/seed_creation_event.rb +1 -1
  96. data/lib/coinbase/client/models/seed_creation_event_result.rb +1 -1
  97. data/lib/coinbase/client/models/server_signer.rb +1 -1
  98. data/lib/coinbase/client/models/server_signer_event.rb +1 -1
  99. data/lib/coinbase/client/models/server_signer_event_event.rb +1 -1
  100. data/lib/coinbase/client/models/server_signer_event_list.rb +1 -1
  101. data/lib/coinbase/client/models/server_signer_list.rb +1 -1
  102. data/lib/coinbase/client/models/signature_creation_event.rb +1 -1
  103. data/lib/coinbase/client/models/signature_creation_event_result.rb +1 -1
  104. data/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb +1 -1
  105. data/lib/coinbase/client/models/smart_contract.rb +37 -31
  106. data/lib/coinbase/client/models/smart_contract_activity_event.rb +386 -0
  107. data/lib/coinbase/client/models/smart_contract_list.rb +1 -1
  108. data/lib/coinbase/client/models/smart_contract_options.rb +1 -1
  109. data/lib/coinbase/client/models/smart_contract_type.rb +3 -2
  110. data/lib/coinbase/client/models/solidity_value.rb +3 -3
  111. data/lib/coinbase/client/models/sponsored_send.rb +1 -1
  112. data/lib/coinbase/client/models/staking_balance.rb +1 -1
  113. data/lib/coinbase/client/models/staking_context.rb +1 -1
  114. data/lib/coinbase/client/models/staking_context_context.rb +1 -1
  115. data/lib/coinbase/client/models/staking_operation.rb +1 -1
  116. data/lib/coinbase/client/models/staking_operation_metadata.rb +1 -1
  117. data/lib/coinbase/client/models/staking_reward.rb +1 -1
  118. data/lib/coinbase/client/models/staking_reward_format.rb +1 -1
  119. data/lib/coinbase/client/models/staking_reward_usd_value.rb +1 -1
  120. data/lib/coinbase/client/models/token_contract_options.rb +1 -1
  121. data/lib/coinbase/client/models/token_transfer_type.rb +1 -1
  122. data/lib/coinbase/client/models/trade.rb +1 -1
  123. data/lib/coinbase/client/models/trade_list.rb +1 -1
  124. data/lib/coinbase/client/models/transaction.rb +1 -1
  125. data/lib/coinbase/client/models/transaction_content.rb +1 -1
  126. data/lib/coinbase/client/models/transaction_type.rb +1 -1
  127. data/lib/coinbase/client/models/transfer.rb +2 -37
  128. data/lib/coinbase/client/models/transfer_list.rb +1 -1
  129. data/lib/coinbase/client/models/update_smart_contract_request.rb +245 -0
  130. data/lib/coinbase/client/models/update_webhook_request.rb +1 -1
  131. data/lib/coinbase/client/models/user.rb +1 -1
  132. data/lib/coinbase/client/models/validator.rb +1 -1
  133. data/lib/coinbase/client/models/validator_details.rb +1 -1
  134. data/lib/coinbase/client/models/validator_list.rb +1 -1
  135. data/lib/coinbase/client/models/validator_status.rb +1 -1
  136. data/lib/coinbase/client/models/wallet.rb +1 -1
  137. data/lib/coinbase/client/models/wallet_list.rb +1 -1
  138. data/lib/coinbase/client/models/webhook.rb +1 -1
  139. data/lib/coinbase/client/models/webhook_event_filter.rb +1 -1
  140. data/lib/coinbase/client/models/webhook_event_type.rb +3 -2
  141. data/lib/coinbase/client/models/webhook_event_type_filter.rb +2 -1
  142. data/lib/coinbase/client/models/webhook_list.rb +1 -1
  143. data/lib/coinbase/client/models/webhook_smart_contract_event_filter.rb +225 -0
  144. data/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +8 -1
  145. data/lib/coinbase/client/version.rb +1 -1
  146. data/lib/coinbase/client.rb +11 -4
  147. data/lib/coinbase/crypto_amount.rb +62 -0
  148. data/lib/coinbase/errors.rb +8 -0
  149. data/lib/coinbase/fiat_amount.rb +40 -0
  150. data/lib/coinbase/fund_operation.rb +228 -0
  151. data/lib/coinbase/fund_quote.rb +149 -0
  152. data/lib/coinbase/smart_contract.rb +337 -244
  153. data/lib/coinbase/staking_operation.rb +2 -2
  154. data/lib/coinbase/validator.rb +7 -10
  155. data/lib/coinbase/version.rb +1 -1
  156. data/lib/coinbase/wallet/data.rb +6 -4
  157. data/lib/coinbase/wallet.rb +16 -3
  158. data/lib/coinbase.rb +6 -1
  159. metadata +20 -8
  160. data/lib/coinbase/client/api/validators_api.rb +0 -179
@@ -0,0 +1,225 @@
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.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # Filter for smart contract events. This filter allows the client to specify smart contract addresses to monitor for activities such as contract function calls.
18
+ class WebhookSmartContractEventFilter
19
+ # A list of smart contract addresses to filter on.
20
+ attr_accessor :contract_addresses
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'contract_addresses' => :'contract_addresses'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'contract_addresses' => :'Array<String>'
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new([
44
+ ])
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ if (!attributes.is_a?(Hash))
51
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::WebhookSmartContractEventFilter` initialize method"
52
+ end
53
+
54
+ # check to see if the attribute exists and convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h|
56
+ if (!self.class.attribute_map.key?(k.to_sym))
57
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::WebhookSmartContractEventFilter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
+ end
59
+ h[k.to_sym] = v
60
+ }
61
+
62
+ if attributes.key?(:'contract_addresses')
63
+ if (value = attributes[:'contract_addresses']).is_a?(Array)
64
+ self.contract_addresses = value
65
+ end
66
+ else
67
+ self.contract_addresses = nil
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
75
+ invalid_properties = Array.new
76
+ if @contract_addresses.nil?
77
+ invalid_properties.push('invalid value for "contract_addresses", contract_addresses cannot be nil.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ warn '[DEPRECATED] the `valid?` method is obsolete'
87
+ return false if @contract_addresses.nil?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ contract_addresses == o.contract_addresses
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [contract_addresses].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ attributes = attributes.transform_keys(&:to_sym)
117
+ transformed_hash = {}
118
+ openapi_types.each_pair do |key, type|
119
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
120
+ transformed_hash["#{key}"] = nil
121
+ elsif type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[attribute_map[key]].is_a?(Array)
125
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
126
+ end
127
+ elsif !attributes[attribute_map[key]].nil?
128
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
129
+ end
130
+ end
131
+ new(transformed_hash)
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def self._deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = Coinbase::Client.const_get(type)
173
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ 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.8.0
9
+ Generator version: 7.10.0
10
10
 
11
11
  =end
12
12
 
@@ -72,6 +72,8 @@ module Coinbase::Client
72
72
 
73
73
  if attributes.key?(:'wallet_id')
74
74
  self.wallet_id = attributes[:'wallet_id']
75
+ else
76
+ self.wallet_id = nil
75
77
  end
76
78
  end
77
79
 
@@ -80,6 +82,10 @@ module Coinbase::Client
80
82
  def list_invalid_properties
81
83
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
82
84
  invalid_properties = Array.new
85
+ if @wallet_id.nil?
86
+ invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.')
87
+ end
88
+
83
89
  invalid_properties
84
90
  end
85
91
 
@@ -87,6 +93,7 @@ module Coinbase::Client
87
93
  # @return true if the model is valid
88
94
  def valid?
89
95
  warn '[DEPRECATED] the `valid?` method is obsolete'
96
+ return false if @wallet_id.nil?
90
97
  true
91
98
  end
92
99
 
@@ -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.8.0
9
+ Generator version: 7.10.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.8.0
9
+ Generator version: 7.10.0
10
10
 
11
11
  =end
12
12
 
@@ -21,13 +21,15 @@ Coinbase::Client.autoload :Address, 'coinbase/client/models/address'
21
21
  Coinbase::Client.autoload :AddressBalanceList, 'coinbase/client/models/address_balance_list'
22
22
  Coinbase::Client.autoload :AddressHistoricalBalanceList, 'coinbase/client/models/address_historical_balance_list'
23
23
  Coinbase::Client.autoload :AddressList, 'coinbase/client/models/address_list'
24
+ Coinbase::Client.autoload :AddressReputation, 'coinbase/client/models/address_reputation'
25
+ Coinbase::Client.autoload :AddressReputationMetadata, 'coinbase/client/models/address_reputation_metadata'
24
26
  Coinbase::Client.autoload :AddressTransactionList, 'coinbase/client/models/address_transaction_list'
25
27
  Coinbase::Client.autoload :Asset, 'coinbase/client/models/asset'
26
28
  Coinbase::Client.autoload :Balance, 'coinbase/client/models/balance'
27
29
  Coinbase::Client.autoload :BroadcastContractInvocationRequest, 'coinbase/client/models/broadcast_contract_invocation_request'
30
+ Coinbase::Client.autoload :BroadcastExternalTransferRequest, 'coinbase/client/models/broadcast_external_transfer_request'
28
31
  Coinbase::Client.autoload :BroadcastStakingOperationRequest, 'coinbase/client/models/broadcast_staking_operation_request'
29
32
  Coinbase::Client.autoload :BroadcastTradeRequest, 'coinbase/client/models/broadcast_trade_request'
30
- Coinbase::Client.autoload :BroadcastTransferRequest, 'coinbase/client/models/broadcast_transfer_request'
31
33
  Coinbase::Client.autoload :BuildStakingOperationRequest, 'coinbase/client/models/build_staking_operation_request'
32
34
  Coinbase::Client.autoload :ContractEvent, 'coinbase/client/models/contract_event'
33
35
  Coinbase::Client.autoload :ContractEventList, 'coinbase/client/models/contract_event_list'
@@ -35,6 +37,7 @@ Coinbase::Client.autoload :ContractInvocation, 'coinbase/client/models/contract_
35
37
  Coinbase::Client.autoload :ContractInvocationList, 'coinbase/client/models/contract_invocation_list'
36
38
  Coinbase::Client.autoload :CreateAddressRequest, 'coinbase/client/models/create_address_request'
37
39
  Coinbase::Client.autoload :CreateContractInvocationRequest, 'coinbase/client/models/create_contract_invocation_request'
40
+ Coinbase::Client.autoload :CreateExternalTransferRequest, 'coinbase/client/models/create_external_transfer_request'
38
41
  Coinbase::Client.autoload :CreateFundOperationRequest, 'coinbase/client/models/create_fund_operation_request'
39
42
  Coinbase::Client.autoload :CreateFundQuoteRequest, 'coinbase/client/models/create_fund_quote_request'
40
43
  Coinbase::Client.autoload :CreatePayloadSignatureRequest, 'coinbase/client/models/create_payload_signature_request'
@@ -79,6 +82,7 @@ Coinbase::Client.autoload :OnchainNameList, 'coinbase/client/models/onchain_name
79
82
  Coinbase::Client.autoload :PayloadSignature, 'coinbase/client/models/payload_signature'
80
83
  Coinbase::Client.autoload :PayloadSignatureList, 'coinbase/client/models/payload_signature_list'
81
84
  Coinbase::Client.autoload :ReadContractRequest, 'coinbase/client/models/read_contract_request'
85
+ Coinbase::Client.autoload :RegisterSmartContractRequest, 'coinbase/client/models/register_smart_contract_request'
82
86
  Coinbase::Client.autoload :SeedCreationEvent, 'coinbase/client/models/seed_creation_event'
83
87
  Coinbase::Client.autoload :SeedCreationEventResult, 'coinbase/client/models/seed_creation_event_result'
84
88
  Coinbase::Client.autoload :ServerSigner, 'coinbase/client/models/server_signer'
@@ -90,6 +94,7 @@ Coinbase::Client.autoload :SignatureCreationEvent, 'coinbase/client/models/signa
90
94
  Coinbase::Client.autoload :SignatureCreationEventResult, 'coinbase/client/models/signature_creation_event_result'
91
95
  Coinbase::Client.autoload :SignedVoluntaryExitMessageMetadata, 'coinbase/client/models/signed_voluntary_exit_message_metadata'
92
96
  Coinbase::Client.autoload :SmartContract, 'coinbase/client/models/smart_contract'
97
+ Coinbase::Client.autoload :SmartContractActivityEvent, 'coinbase/client/models/smart_contract_activity_event'
93
98
  Coinbase::Client.autoload :SmartContractList, 'coinbase/client/models/smart_contract_list'
94
99
  Coinbase::Client.autoload :SmartContractOptions, 'coinbase/client/models/smart_contract_options'
95
100
  Coinbase::Client.autoload :SmartContractType, 'coinbase/client/models/smart_contract_type'
@@ -112,6 +117,7 @@ Coinbase::Client.autoload :TransactionContent, 'coinbase/client/models/transacti
112
117
  Coinbase::Client.autoload :TransactionType, 'coinbase/client/models/transaction_type'
113
118
  Coinbase::Client.autoload :Transfer, 'coinbase/client/models/transfer'
114
119
  Coinbase::Client.autoload :TransferList, 'coinbase/client/models/transfer_list'
120
+ Coinbase::Client.autoload :UpdateSmartContractRequest, 'coinbase/client/models/update_smart_contract_request'
115
121
  Coinbase::Client.autoload :UpdateWebhookRequest, 'coinbase/client/models/update_webhook_request'
116
122
  Coinbase::Client.autoload :User, 'coinbase/client/models/user'
117
123
  Coinbase::Client.autoload :Validator, 'coinbase/client/models/validator'
@@ -125,6 +131,7 @@ Coinbase::Client.autoload :WebhookEventFilter, 'coinbase/client/models/webhook_e
125
131
  Coinbase::Client.autoload :WebhookEventType, 'coinbase/client/models/webhook_event_type'
126
132
  Coinbase::Client.autoload :WebhookEventTypeFilter, 'coinbase/client/models/webhook_event_type_filter'
127
133
  Coinbase::Client.autoload :WebhookList, 'coinbase/client/models/webhook_list'
134
+ Coinbase::Client.autoload :WebhookSmartContractEventFilter, 'coinbase/client/models/webhook_smart_contract_event_filter'
128
135
  Coinbase::Client.autoload :WebhookWalletActivityFilter, 'coinbase/client/models/webhook_wallet_activity_filter'
129
136
 
130
137
  # APIs
@@ -135,8 +142,10 @@ Coinbase::Client.autoload :ContractEventsApi, 'coinbase/client/api/contract_even
135
142
  Coinbase::Client.autoload :ContractInvocationsApi, 'coinbase/client/api/contract_invocations_api'
136
143
  Coinbase::Client.autoload :ExternalAddressesApi, 'coinbase/client/api/external_addresses_api'
137
144
  Coinbase::Client.autoload :FundApi, 'coinbase/client/api/fund_api'
145
+ Coinbase::Client.autoload :MPCWalletStakeApi, 'coinbase/client/api/mpc_wallet_stake_api'
138
146
  Coinbase::Client.autoload :NetworksApi, 'coinbase/client/api/networks_api'
139
147
  Coinbase::Client.autoload :OnchainIdentityApi, 'coinbase/client/api/onchain_identity_api'
148
+ Coinbase::Client.autoload :ReputationApi, 'coinbase/client/api/reputation_api'
140
149
  Coinbase::Client.autoload :ServerSignersApi, 'coinbase/client/api/server_signers_api'
141
150
  Coinbase::Client.autoload :SmartContractsApi, 'coinbase/client/api/smart_contracts_api'
142
151
  Coinbase::Client.autoload :StakeApi, 'coinbase/client/api/stake_api'
@@ -144,8 +153,6 @@ Coinbase::Client.autoload :TradesApi, 'coinbase/client/api/trades_api'
144
153
  Coinbase::Client.autoload :TransactionHistoryApi, 'coinbase/client/api/transaction_history_api'
145
154
  Coinbase::Client.autoload :TransfersApi, 'coinbase/client/api/transfers_api'
146
155
  Coinbase::Client.autoload :UsersApi, 'coinbase/client/api/users_api'
147
- Coinbase::Client.autoload :ValidatorsApi, 'coinbase/client/api/validators_api'
148
- Coinbase::Client.autoload :WalletStakeApi, 'coinbase/client/api/wallet_stake_api'
149
156
  Coinbase::Client.autoload :WalletsApi, 'coinbase/client/api/wallets_api'
150
157
  Coinbase::Client.autoload :WebhooksApi, 'coinbase/client/api/webhooks_api'
151
158
 
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coinbase
4
+ # A representation of a CryptoAmount that includes the amount and asset.
5
+ class CryptoAmount
6
+ # Converts a Coinbase::Client::CryptoAmount model to a Coinbase::CryptoAmount
7
+ # @param amount_model [Coinbase::Client::CryptoAmount] The crypto amount from the API.
8
+ # @return [CryptoAmount] The converted CryptoAmount object.
9
+ def self.from_model(amount_model)
10
+ asset = Coinbase::Asset.from_model(amount_model.asset)
11
+
12
+ new(amount: asset.from_atomic_amount(amount_model.amount), asset: asset)
13
+ end
14
+
15
+ # Converts a Coinbase::Client::CryptoAmount model and asset ID to a Coinbase::CryptoAmount
16
+ # This can be used to specify a non-primary denomination that we want the amount
17
+ # to be converted to.
18
+ # @param amount_model [Coinbase::Client::CryptoAmount] The crypto amount from the API.
19
+ # @param asset_id [Symbol] The Asset ID of the denomination we want returned.
20
+ # @return [CryptoAmount] The converted CryptoAmount object.
21
+ def self.from_model_and_asset_id(amount_model, asset_id)
22
+ asset = Coinbase::Asset.from_model(amount_model.asset, asset_id: asset_id)
23
+
24
+ new(
25
+ amount: asset.from_atomic_amount(amount_model.amount),
26
+ asset: asset,
27
+ asset_id: asset_id
28
+ )
29
+ end
30
+
31
+ # Returns a new CryptoAmount object. Do not use this method.
32
+ # Instead, use CryptoAmount.from_model or CryptoAmount.from_model_and_asset_id.
33
+ # @param amount [BigDecimal] The amount of the Asset
34
+ # @param asset [Coinbase::Asset] The Asset
35
+ # @param asset_id [Symbol] The Asset ID
36
+ def initialize(amount:, asset:, asset_id: nil)
37
+ @amount = amount
38
+ @asset = asset
39
+ @asset_id = asset_id || asset.asset_id
40
+ end
41
+
42
+ attr_reader :amount, :asset, :asset_id
43
+
44
+ # Returns the amount in atomic units.
45
+ # @return [BigDecimal] the amount in atomic units
46
+ def to_atomic_amount
47
+ asset.to_atomic_amount(amount)
48
+ end
49
+
50
+ # Returns a string representation of the CryptoAmount.
51
+ # @return [String] a string representation of the CryptoAmount
52
+ def to_s
53
+ Coinbase.pretty_print_object(self.class, amount: amount.to_s('F'), asset_id: asset_id)
54
+ end
55
+
56
+ # Same as to_s.
57
+ # @return [String] a string representation of the CryptoAmount
58
+ def inspect
59
+ to_s
60
+ end
61
+ end
62
+ end
@@ -84,6 +84,14 @@ module Coinbase
84
84
  end
85
85
  end
86
86
 
87
+ # An error raised when attempting to manage an external contract on-chain,
88
+ # e.g. sign the deployment tx, deploy the contract, etc...
89
+ class ManageExternalContractError < StandardError
90
+ def initialize(action = 'manage')
91
+ super("Cannot #{action} external smart contract")
92
+ end
93
+ end
94
+
87
95
  # An error raised when an address attempts to sign a transaction without a private key.
88
96
  class AddressCannotSignError < StandardError
89
97
  def initialize(msg = 'Address cannot sign transaction without private key loaded')
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coinbase
4
+ # A representation of a FiatAmount that includes the amount and fiat.
5
+ class FiatAmount
6
+ # Converts a Coinbase::Client::FiatAmount model to a Coinbase::FiatAmount
7
+ # @param model [Coinbase::Client::FiatAmount] The crypto amount from the API.
8
+ # @return [FiatAmount] The converted FiatAmount object.
9
+ def self.from_model(model)
10
+ unless model.is_a?(Coinbase::Client::FiatAmount)
11
+ raise ArgumentError,
12
+ 'model must be a Coinbase::Client::FiatAmount'
13
+ end
14
+
15
+ new(amount: model.amount, currency: model.currency)
16
+ end
17
+
18
+ # Returns a new FiatAmount object.
19
+ # @param amount [BigDecimal, String] The amount of the Fiat Currency
20
+ # @param currency [Symbol, String] The currency of the Fiat Amount
21
+ def initialize(amount:, currency:)
22
+ @amount = BigDecimal(amount)
23
+ @currency = Coinbase.to_sym(currency)
24
+ end
25
+
26
+ attr_reader :amount, :currency
27
+
28
+ # Returns a string representation of the FiatAmount.
29
+ # @return [String] a string representation of the FiatAmount
30
+ def to_s
31
+ Coinbase.pretty_print_object(self.class, amount: amount.to_s('F'), currency: currency)
32
+ end
33
+
34
+ # Same as to_s.
35
+ # @return [String] a string representation of the FiatAmount
36
+ def inspect
37
+ to_s
38
+ end
39
+ end
40
+ end