coinbase-sdk 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,222 @@
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.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ class BroadcastTransferRequest
18
+ # The hex-encoded signed payload of the transfer
19
+ attr_accessor :signed_payload
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'signed_payload' => :'signed_payload'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'signed_payload' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::BroadcastTransferRequest` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::BroadcastTransferRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'signed_payload')
62
+ self.signed_payload = attributes[:'signed_payload']
63
+ else
64
+ self.signed_payload = nil
65
+ end
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
72
+ invalid_properties = Array.new
73
+ if @signed_payload.nil?
74
+ invalid_properties.push('invalid value for "signed_payload", signed_payload cannot be nil.')
75
+ end
76
+
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ warn '[DEPRECATED] the `valid?` method is obsolete'
84
+ return false if @signed_payload.nil?
85
+ true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ signed_payload == o.signed_payload
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [signed_payload].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ attributes = attributes.transform_keys(&:to_sym)
114
+ transformed_hash = {}
115
+ openapi_types.each_pair do |key, type|
116
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
117
+ transformed_hash["#{key}"] = nil
118
+ elsif type =~ /\AArray<(.*)>/i
119
+ # check to ensure the input is an array given that the attribute
120
+ # is documented as an array but the input is not
121
+ if attributes[attribute_map[key]].is_a?(Array)
122
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
123
+ end
124
+ elsif !attributes[attribute_map[key]].nil?
125
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
126
+ end
127
+ end
128
+ new(transformed_hash)
129
+ end
130
+
131
+ # Deserializes the data based on type
132
+ # @param string type Data type
133
+ # @param string value Value to be deserialized
134
+ # @return [Object] Deserialized data
135
+ def self._deserialize(type, value)
136
+ case type.to_sym
137
+ when :Time
138
+ Time.parse(value)
139
+ when :Date
140
+ Date.parse(value)
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :Boolean
148
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ # models (e.g. Pet) or oneOf
169
+ klass = Coinbase::Client.const_get(type)
170
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
171
+ end
172
+ end
173
+
174
+ # Returns the string representation of the object
175
+ # @return [String] String presentation of the object
176
+ def to_s
177
+ to_hash.to_s
178
+ end
179
+
180
+ # to_body is an alias to to_hash (backward compatibility)
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_body
183
+ to_hash
184
+ end
185
+
186
+ # Returns the object in the form of hash
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_hash
189
+ hash = {}
190
+ self.class.attribute_map.each_pair do |attr, param|
191
+ value = self.send(attr)
192
+ if value.nil?
193
+ is_nullable = self.class.openapi_nullable.include?(attr)
194
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
195
+ end
196
+
197
+ hash[param] = _to_hash(value)
198
+ end
199
+ hash
200
+ end
201
+
202
+ # Outputs non-array value in the form of hash
203
+ # For object, use to_hash. Otherwise, just return the value
204
+ # @param [Object] value Any valid value
205
+ # @return [Hash] Returns the value in the form of hash
206
+ def _to_hash(value)
207
+ if value.is_a?(Array)
208
+ value.compact.map { |v| _to_hash(v) }
209
+ elsif value.is_a?(Hash)
210
+ {}.tap do |hash|
211
+ value.each { |k, v| hash[k] = _to_hash(v) }
212
+ end
213
+ elsif value.respond_to? :to_hash
214
+ value.to_hash
215
+ else
216
+ value
217
+ end
218
+ end
219
+
220
+ end
221
+
222
+ end
@@ -0,0 +1,222 @@
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.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ class FaucetTransaction
18
+ # The transaction hash of the transaction the faucet created.
19
+ attr_accessor :transaction_hash
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'transaction_hash' => :'transaction_hash'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'transaction_hash' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::FaucetTransaction` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::FaucetTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'transaction_hash')
62
+ self.transaction_hash = attributes[:'transaction_hash']
63
+ else
64
+ self.transaction_hash = nil
65
+ end
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
72
+ invalid_properties = Array.new
73
+ if @transaction_hash.nil?
74
+ invalid_properties.push('invalid value for "transaction_hash", transaction_hash cannot be nil.')
75
+ end
76
+
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ warn '[DEPRECATED] the `valid?` method is obsolete'
84
+ return false if @transaction_hash.nil?
85
+ true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ transaction_hash == o.transaction_hash
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [transaction_hash].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ attributes = attributes.transform_keys(&:to_sym)
114
+ transformed_hash = {}
115
+ openapi_types.each_pair do |key, type|
116
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
117
+ transformed_hash["#{key}"] = nil
118
+ elsif type =~ /\AArray<(.*)>/i
119
+ # check to ensure the input is an array given that the attribute
120
+ # is documented as an array but the input is not
121
+ if attributes[attribute_map[key]].is_a?(Array)
122
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
123
+ end
124
+ elsif !attributes[attribute_map[key]].nil?
125
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
126
+ end
127
+ end
128
+ new(transformed_hash)
129
+ end
130
+
131
+ # Deserializes the data based on type
132
+ # @param string type Data type
133
+ # @param string value Value to be deserialized
134
+ # @return [Object] Deserialized data
135
+ def self._deserialize(type, value)
136
+ case type.to_sym
137
+ when :Time
138
+ Time.parse(value)
139
+ when :Date
140
+ Date.parse(value)
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :Boolean
148
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ # models (e.g. Pet) or oneOf
169
+ klass = Coinbase::Client.const_get(type)
170
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
171
+ end
172
+ end
173
+
174
+ # Returns the string representation of the object
175
+ # @return [String] String presentation of the object
176
+ def to_s
177
+ to_hash.to_s
178
+ end
179
+
180
+ # to_body is an alias to to_hash (backward compatibility)
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_body
183
+ to_hash
184
+ end
185
+
186
+ # Returns the object in the form of hash
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_hash
189
+ hash = {}
190
+ self.class.attribute_map.each_pair do |attr, param|
191
+ value = self.send(attr)
192
+ if value.nil?
193
+ is_nullable = self.class.openapi_nullable.include?(attr)
194
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
195
+ end
196
+
197
+ hash[param] = _to_hash(value)
198
+ end
199
+ hash
200
+ end
201
+
202
+ # Outputs non-array value in the form of hash
203
+ # For object, use to_hash. Otherwise, just return the value
204
+ # @param [Object] value Any valid value
205
+ # @return [Hash] Returns the value in the form of hash
206
+ def _to_hash(value)
207
+ if value.is_a?(Array)
208
+ value.compact.map { |v| _to_hash(v) }
209
+ elsif value.is_a?(Hash)
210
+ {}.tap do |hash|
211
+ value.each { |k, v| hash[k] = _to_hash(v) }
212
+ end
213
+ elsif value.respond_to? :to_hash
214
+ value.to_hash
215
+ else
216
+ value
217
+ end
218
+ end
219
+
220
+ end
221
+
222
+ end
@@ -40,6 +40,12 @@ module Coinbase::Client
40
40
  # The unsigned payload of the transfer. This is the payload that needs to be signed by the sender.
41
41
  attr_accessor :unsigned_payload
42
42
 
43
+ # The signed payload of the transfer. This is the payload that has been signed by the sender.
44
+ attr_accessor :signed_payload
45
+
46
+ # The hash of the transfer transaction
47
+ attr_accessor :transaction_hash
48
+
43
49
  # The status of the transfer
44
50
  attr_accessor :status
45
51
 
@@ -76,6 +82,8 @@ module Coinbase::Client
76
82
  :'asset_id' => :'asset_id',
77
83
  :'transfer_id' => :'transfer_id',
78
84
  :'unsigned_payload' => :'unsigned_payload',
85
+ :'signed_payload' => :'signed_payload',
86
+ :'transaction_hash' => :'transaction_hash',
79
87
  :'status' => :'status'
80
88
  }
81
89
  end
@@ -96,6 +104,8 @@ module Coinbase::Client
96
104
  :'asset_id' => :'String',
97
105
  :'transfer_id' => :'String',
98
106
  :'unsigned_payload' => :'String',
107
+ :'signed_payload' => :'String',
108
+ :'transaction_hash' => :'String',
99
109
  :'status' => :'String'
100
110
  }
101
111
  end
@@ -169,6 +179,14 @@ module Coinbase::Client
169
179
  self.unsigned_payload = nil
170
180
  end
171
181
 
182
+ if attributes.key?(:'signed_payload')
183
+ self.signed_payload = attributes[:'signed_payload']
184
+ end
185
+
186
+ if attributes.key?(:'transaction_hash')
187
+ self.transaction_hash = attributes[:'transaction_hash']
188
+ end
189
+
172
190
  if attributes.key?(:'status')
173
191
  self.status = attributes[:'status']
174
192
  else
@@ -261,6 +279,8 @@ module Coinbase::Client
261
279
  asset_id == o.asset_id &&
262
280
  transfer_id == o.transfer_id &&
263
281
  unsigned_payload == o.unsigned_payload &&
282
+ signed_payload == o.signed_payload &&
283
+ transaction_hash == o.transaction_hash &&
264
284
  status == o.status
265
285
  end
266
286
 
@@ -273,7 +293,7 @@ module Coinbase::Client
273
293
  # Calculates hash code according to all attributes.
274
294
  # @return [Integer] Hash code
275
295
  def hash
276
- [network_id, wallet_id, address_id, destination, amount, asset_id, transfer_id, unsigned_payload, status].hash
296
+ [network_id, wallet_id, address_id, destination, amount, asset_id, transfer_id, unsigned_payload, signed_payload, transaction_hash, status].hash
277
297
  end
278
298
 
279
299
  # Builds the object from hash
@@ -22,10 +22,12 @@ Coinbase::Client.autoload :AddressBalanceList, 'coinbase/client/models/address_b
22
22
  Coinbase::Client.autoload :AddressList, 'coinbase/client/models/address_list'
23
23
  Coinbase::Client.autoload :Asset, 'coinbase/client/models/asset'
24
24
  Coinbase::Client.autoload :Balance, 'coinbase/client/models/balance'
25
+ Coinbase::Client.autoload :BroadcastTransferRequest, 'coinbase/client/models/broadcast_transfer_request'
25
26
  Coinbase::Client.autoload :CreateAddressRequest, 'coinbase/client/models/create_address_request'
26
27
  Coinbase::Client.autoload :CreateTransferRequest, 'coinbase/client/models/create_transfer_request'
27
28
  Coinbase::Client.autoload :CreateWalletRequest, 'coinbase/client/models/create_wallet_request'
28
29
  Coinbase::Client.autoload :Error, 'coinbase/client/models/error'
30
+ Coinbase::Client.autoload :FaucetTransaction, 'coinbase/client/models/faucet_transaction'
29
31
  Coinbase::Client.autoload :Transfer, 'coinbase/client/models/transfer'
30
32
  Coinbase::Client.autoload :TransferList, 'coinbase/client/models/transfer_list'
31
33
  Coinbase::Client.autoload :User, 'coinbase/client/models/user'
@@ -8,7 +8,8 @@ module Coinbase
8
8
  ETH = Asset.new(network_id: :base_sepolia, asset_id: :eth, display_name: 'Ether')
9
9
  USDC = Asset.new(network_id: :base_sepolia, asset_id: :usdc, display_name: 'USD Coin',
10
10
  address_id: '0x036CbD53842c5426634e7929541eC2318f3dCF7e')
11
-
11
+ WETH = Asset.new(network_id: :base_sepolia, asset_id: :weth, display_name: 'Wrapped Ether',
12
+ address_id: '0x4200000000000000000000000000000000000006')
12
13
  # The Base Sepolia Network.
13
14
  BASE_SEPOLIA = Network.new(
14
15
  network_id: :base_sepolia,
@@ -37,6 +38,7 @@ module Coinbase
37
38
  eth: true, # Ether, the native asset of most EVM networks.
38
39
  gwei: true, # A medium denomination of Ether, typically used in gas prices.
39
40
  wei: true, # The smallest denomination of Ether.
40
- usdc: true # USD Coin, a stablecoin pegged to the US Dollar.
41
+ usdc: true, # USD Coin, a stablecoin pegged to the US Dollar.
42
+ weth: true # Wrapped Ether, the ERC-20 compatible version of Ether.
41
43
  }.freeze
42
44
  end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'client/api_error'
4
+ require 'json'
5
+
6
+ module Coinbase
7
+ # A wrapper for API errors to provide more context.
8
+ class APIError < StandardError
9
+ attr_reader :http_code, :api_code, :api_message
10
+
11
+ # Initializes a new APIError object.
12
+ # @param err [Coinbase::Client::APIError] The underlying error object.
13
+ def initialize(err)
14
+ super
15
+ @http_code = err.code
16
+
17
+ return unless err.response_body
18
+
19
+ body = JSON.parse(err.response_body)
20
+ @api_code = body['code']
21
+ @api_message = body['message']
22
+ end
23
+
24
+ # Creates a specific APIError based on the API error code.
25
+ # @param err [Coinbase::Client::APIError] The underlying error object.
26
+ # @return [APIError] The specific APIError object.
27
+ # rubocop:disable Metrics/MethodLength
28
+ def self.from_error(err)
29
+ raise ArgumentError, 'Argument must be a Coinbase::Client::APIError' unless err.is_a? Coinbase::Client::ApiError
30
+ return APIError.new(err) unless err.response_body
31
+
32
+ body = JSON.parse(err.response_body)
33
+
34
+ case body['code']
35
+ when 'unimplemented'
36
+ UnimplementedError.new(err)
37
+ when 'unauthorized'
38
+ UnauthorizedError.new(err)
39
+ when 'internal'
40
+ InternalError.new(err)
41
+ when 'not_found'
42
+ NotFoundError.new(err)
43
+ when 'invalid_wallet_id'
44
+ InvalidWalletIDError.new(err)
45
+ when 'invalid_address_id'
46
+ InvalidAddressIDError.new(err)
47
+ when 'invalid_wallet'
48
+ InvalidWalletError.new(err)
49
+ when 'invalid_address'
50
+ InvalidAddressError.new(err)
51
+ when 'invalid_amount'
52
+ InvalidAmountError.new(err)
53
+ when 'invalid_transfer_id'
54
+ InvalidTransferIDError.new(err)
55
+ when 'invalid_page_token'
56
+ InvalidPageError.new(err)
57
+ when 'invalid_page_limit'
58
+ InvalidLimitError.new(err)
59
+ when 'already_exists'
60
+ AlreadyExistsError.new(err)
61
+ when 'malformed_request'
62
+ MalformedRequestError.new(err)
63
+ when 'unsupported_asset'
64
+ UnsupportedAssetError.new(err)
65
+ when 'invalid_asset_id'
66
+ InvalidAssetIDError.new(err)
67
+ when 'invalid_destination'
68
+ InvalidDestinationError.new(err)
69
+ when 'invalid_network_id'
70
+ InvalidNetworkIDError.new(err)
71
+ when 'resource_exhausted'
72
+ ResourceExhaustedError.new(err)
73
+ when 'faucet_limit_reached'
74
+ FaucetLimitReachedError.new(err)
75
+ when 'invalid_signed_payload'
76
+ InvalidSignedPayloadError.new(err)
77
+ when 'invalid_transfer_status'
78
+ InvalidTransferStatusError.new(err)
79
+ else
80
+ APIError.new(err)
81
+ end
82
+ end
83
+ # rubocop:enable Metrics/MethodLength
84
+
85
+ # Returns a String representation of the APIError.
86
+ # @return [String] a String representation of the APIError
87
+ def to_s
88
+ "APIError{http_code: #{@http_code}, api_code: #{@api_code}, api_message: #{@api_message}}"
89
+ end
90
+
91
+ # Same as to_s.
92
+ # @return [String] a String representation of the APIError
93
+ def inspect
94
+ to_s
95
+ end
96
+ end
97
+
98
+ class UnimplementedError < APIError; end
99
+ class UnauthorizedError < APIError; end
100
+ class InternalError < APIError; end
101
+ class NotFoundError < APIError; end
102
+ class InvalidWalletIDError < APIError; end
103
+ class InvalidAddressIDError < APIError; end
104
+ class InvalidWalletError < APIError; end
105
+ class InvalidAddressError < APIError; end
106
+ class InvalidAmountError < APIError; end
107
+ class InvalidTransferIDError < APIError; end
108
+ class InvalidPageError < APIError; end
109
+ class InvalidLimitError < APIError; end
110
+ class AlreadyExistsError < APIError; end
111
+ class MalformedRequestError < APIError; end
112
+ class UnsupportedAssetError < APIError; end
113
+ class InvalidAssetIDError < APIError; end
114
+ class InvalidDestinationError < APIError; end
115
+ class InvalidNetworkIDError < APIError; end
116
+ class ResourceExhaustedError < APIError; end
117
+ class FaucetLimitReachedError < APIError; end
118
+ class InvalidSignedPayloadError < APIError; end
119
+ class InvalidTransferStatusError < APIError; end
120
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coinbase
4
+ # A representation of a transaction from a faucet.
5
+ # a user-controlled Wallet to another address. The fee is assumed to be paid
6
+ # in the native Asset of the Network. Transfers should be created through Wallet#transfer or
7
+ # Address#transfer.
8
+ class FaucetTransaction
9
+ # Returns a new FaucetTransaction object. Do not use this method directly - instead, use Address#faucet.
10
+ # @param model [Coinbase::Client::FaucetTransaction] The underlying FaucetTransaction object
11
+ def initialize(model)
12
+ @model = model
13
+ end
14
+
15
+ attr_reader :model
16
+
17
+ # Returns the transaction hash.
18
+ # @return [String] The onchain transaction hash
19
+ def transaction_hash
20
+ model.transaction_hash
21
+ end
22
+
23
+ # Returns the link to the transaction on the blockchain explorer.
24
+ # @return [String] The link to the transaction on the blockchain explorer
25
+ def transaction_link
26
+ # TODO: Parameterize this by Network.
27
+ "https://sepolia.basescan.org/tx/#{transaction_hash}"
28
+ end
29
+
30
+ # Returns a String representation of the FaucetTransaction.
31
+ # @return [String] a String representation of the FaucetTransaction
32
+ def to_s
33
+ "Coinbase::FaucetTransaction{transaction_hash: '#{transaction_hash}', transaction_link: '#{transaction_link}'}"
34
+ end
35
+
36
+ # Same as to_s.
37
+ # @return [String] a String representation of the FaucetTransaction
38
+ def inspect
39
+ to_s
40
+ end
41
+ end
42
+ end