coinbase-sdk 0.7.0 → 0.10.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.
- checksums.yaml +4 -4
- data/lib/coinbase/address.rb +8 -3
- data/lib/coinbase/client/api/external_addresses_api.rb +78 -0
- data/lib/coinbase/client/api/fund_api.rb +336 -0
- data/lib/coinbase/client/api/onchain_identity_api.rb +108 -0
- data/lib/coinbase/client/api/smart_contracts_api.rb +80 -0
- data/lib/coinbase/client/api/webhooks_api.rb +5 -5
- data/lib/coinbase/client/models/create_fund_operation_request.rb +249 -0
- data/lib/coinbase/client/models/create_fund_quote_request.rb +239 -0
- data/lib/coinbase/client/models/create_wallet_webhook_request.rb +1 -1
- data/lib/coinbase/client/models/crypto_amount.rb +239 -0
- data/lib/coinbase/client/models/ethereum_token_transfer.rb +327 -0
- data/lib/coinbase/client/models/ethereum_transaction.rb +12 -1
- data/lib/coinbase/client/models/faucet_transaction.rb +20 -4
- data/lib/coinbase/client/models/fiat_amount.rb +240 -0
- data/lib/coinbase/client/models/fund_operation.rb +373 -0
- data/lib/coinbase/client/models/fund_operation_fees.rb +238 -0
- data/lib/coinbase/client/models/fund_operation_list.rb +275 -0
- data/lib/coinbase/client/models/fund_quote.rb +339 -0
- data/lib/coinbase/client/models/onchain_name.rb +357 -0
- data/lib/coinbase/client/models/onchain_name_list.rb +262 -0
- data/lib/coinbase/client/models/read_contract_request.rb +249 -0
- data/lib/coinbase/client/models/solidity_value.rb +287 -0
- data/lib/coinbase/client/models/token_transfer_type.rb +43 -0
- data/lib/coinbase/client/models/update_webhook_request.rb +0 -7
- data/lib/coinbase/client.rb +17 -0
- data/lib/coinbase/faucet_transaction.rb +64 -4
- data/lib/coinbase/smart_contract.rb +95 -0
- data/lib/coinbase/transaction.rb +8 -2
- data/lib/coinbase/version.rb +1 -1
- metadata +18 -2
@@ -0,0 +1,287 @@
|
|
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
|
+
class SolidityValue
|
18
|
+
attr_accessor :type
|
19
|
+
|
20
|
+
# The field name for tuple types. Not used for other types.
|
21
|
+
attr_accessor :name
|
22
|
+
|
23
|
+
# The value as a string for simple types. Not used for complex types (array, tuple).
|
24
|
+
attr_accessor :value
|
25
|
+
|
26
|
+
# For array and tuple types, the components of the value
|
27
|
+
attr_accessor :values
|
28
|
+
|
29
|
+
class EnumAttributeValidator
|
30
|
+
attr_reader :datatype
|
31
|
+
attr_reader :allowable_values
|
32
|
+
|
33
|
+
def initialize(datatype, allowable_values)
|
34
|
+
@allowable_values = allowable_values.map do |value|
|
35
|
+
case datatype.to_s
|
36
|
+
when /Integer/i
|
37
|
+
value.to_i
|
38
|
+
when /Float/i
|
39
|
+
value.to_f
|
40
|
+
else
|
41
|
+
value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid?(value)
|
47
|
+
!value || allowable_values.include?(value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
52
|
+
def self.attribute_map
|
53
|
+
{
|
54
|
+
:'type' => :'type',
|
55
|
+
:'name' => :'name',
|
56
|
+
:'value' => :'value',
|
57
|
+
:'values' => :'values'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns all the JSON keys this model knows about
|
62
|
+
def self.acceptable_attributes
|
63
|
+
attribute_map.values
|
64
|
+
end
|
65
|
+
|
66
|
+
# Attribute type mapping.
|
67
|
+
def self.openapi_types
|
68
|
+
{
|
69
|
+
:'type' => :'String',
|
70
|
+
:'name' => :'String',
|
71
|
+
:'value' => :'String',
|
72
|
+
:'values' => :'Array<SolidityValue>'
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
# List of attributes with nullable: true
|
77
|
+
def self.openapi_nullable
|
78
|
+
Set.new([
|
79
|
+
])
|
80
|
+
end
|
81
|
+
|
82
|
+
# Initializes the object
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
84
|
+
def initialize(attributes = {})
|
85
|
+
if (!attributes.is_a?(Hash))
|
86
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::SolidityValue` initialize method"
|
87
|
+
end
|
88
|
+
|
89
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
90
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
91
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
92
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::SolidityValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
93
|
+
end
|
94
|
+
h[k.to_sym] = v
|
95
|
+
}
|
96
|
+
|
97
|
+
if attributes.key?(:'type')
|
98
|
+
self.type = attributes[:'type']
|
99
|
+
else
|
100
|
+
self.type = nil
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.key?(:'name')
|
104
|
+
self.name = attributes[:'name']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.key?(:'value')
|
108
|
+
self.value = attributes[:'value']
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.key?(:'values')
|
112
|
+
if (value = attributes[:'values']).is_a?(Array)
|
113
|
+
self.values = value
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
119
|
+
# @return Array for valid properties with the reasons
|
120
|
+
def list_invalid_properties
|
121
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
122
|
+
invalid_properties = Array.new
|
123
|
+
if @type.nil?
|
124
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
125
|
+
end
|
126
|
+
|
127
|
+
invalid_properties
|
128
|
+
end
|
129
|
+
|
130
|
+
# Check to see if the all the properties in the model are valid
|
131
|
+
# @return true if the model is valid
|
132
|
+
def valid?
|
133
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
134
|
+
return false if @type.nil?
|
135
|
+
type_validator = EnumAttributeValidator.new('String', ["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int8", "int16", "int32", "int64", "int128", "int256", "address", "bool", "string", "bytes", "bytes1", "bytes2", "bytes3", "bytes4", "bytes5", "bytes6", "bytes7", "bytes8", "bytes9", "bytes10", "bytes11", "bytes12", "bytes13", "bytes14", "bytes15", "bytes16", "bytes17", "bytes18", "bytes19", "bytes20", "bytes21", "bytes22", "bytes23", "bytes24", "bytes25", "bytes26", "bytes27", "bytes28", "bytes29", "bytes30", "bytes31", "bytes32", "array", "tuple", "unknown_default_open_api"])
|
136
|
+
return false unless type_validator.valid?(@type)
|
137
|
+
true
|
138
|
+
end
|
139
|
+
|
140
|
+
# Custom attribute writer method checking allowed values (enum).
|
141
|
+
# @param [Object] type Object to be assigned
|
142
|
+
def type=(type)
|
143
|
+
validator = EnumAttributeValidator.new('String', ["uint8", "uint16", "uint32", "uint64", "uint128", "uint256", "int8", "int16", "int32", "int64", "int128", "int256", "address", "bool", "string", "bytes", "bytes1", "bytes2", "bytes3", "bytes4", "bytes5", "bytes6", "bytes7", "bytes8", "bytes9", "bytes10", "bytes11", "bytes12", "bytes13", "bytes14", "bytes15", "bytes16", "bytes17", "bytes18", "bytes19", "bytes20", "bytes21", "bytes22", "bytes23", "bytes24", "bytes25", "bytes26", "bytes27", "bytes28", "bytes29", "bytes30", "bytes31", "bytes32", "array", "tuple", "unknown_default_open_api"])
|
144
|
+
unless validator.valid?(type)
|
145
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
146
|
+
end
|
147
|
+
@type = type
|
148
|
+
end
|
149
|
+
|
150
|
+
# Checks equality by comparing each attribute.
|
151
|
+
# @param [Object] Object to be compared
|
152
|
+
def ==(o)
|
153
|
+
return true if self.equal?(o)
|
154
|
+
self.class == o.class &&
|
155
|
+
type == o.type &&
|
156
|
+
name == o.name &&
|
157
|
+
value == o.value &&
|
158
|
+
values == o.values
|
159
|
+
end
|
160
|
+
|
161
|
+
# @see the `==` method
|
162
|
+
# @param [Object] Object to be compared
|
163
|
+
def eql?(o)
|
164
|
+
self == o
|
165
|
+
end
|
166
|
+
|
167
|
+
# Calculates hash code according to all attributes.
|
168
|
+
# @return [Integer] Hash code
|
169
|
+
def hash
|
170
|
+
[type, name, value, values].hash
|
171
|
+
end
|
172
|
+
|
173
|
+
# Builds the object from hash
|
174
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
175
|
+
# @return [Object] Returns the model itself
|
176
|
+
def self.build_from_hash(attributes)
|
177
|
+
return nil unless attributes.is_a?(Hash)
|
178
|
+
attributes = attributes.transform_keys(&:to_sym)
|
179
|
+
transformed_hash = {}
|
180
|
+
openapi_types.each_pair do |key, type|
|
181
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
182
|
+
transformed_hash["#{key}"] = nil
|
183
|
+
elsif type =~ /\AArray<(.*)>/i
|
184
|
+
# check to ensure the input is an array given that the attribute
|
185
|
+
# is documented as an array but the input is not
|
186
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
187
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
188
|
+
end
|
189
|
+
elsif !attributes[attribute_map[key]].nil?
|
190
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
191
|
+
end
|
192
|
+
end
|
193
|
+
new(transformed_hash)
|
194
|
+
end
|
195
|
+
|
196
|
+
# Deserializes the data based on type
|
197
|
+
# @param string type Data type
|
198
|
+
# @param string value Value to be deserialized
|
199
|
+
# @return [Object] Deserialized data
|
200
|
+
def self._deserialize(type, value)
|
201
|
+
case type.to_sym
|
202
|
+
when :Time
|
203
|
+
Time.parse(value)
|
204
|
+
when :Date
|
205
|
+
Date.parse(value)
|
206
|
+
when :String
|
207
|
+
value.to_s
|
208
|
+
when :Integer
|
209
|
+
value.to_i
|
210
|
+
when :Float
|
211
|
+
value.to_f
|
212
|
+
when :Boolean
|
213
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
214
|
+
true
|
215
|
+
else
|
216
|
+
false
|
217
|
+
end
|
218
|
+
when :Object
|
219
|
+
# generic object (usually a Hash), return directly
|
220
|
+
value
|
221
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
222
|
+
inner_type = Regexp.last_match[:inner_type]
|
223
|
+
value.map { |v| _deserialize(inner_type, v) }
|
224
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
225
|
+
k_type = Regexp.last_match[:k_type]
|
226
|
+
v_type = Regexp.last_match[:v_type]
|
227
|
+
{}.tap do |hash|
|
228
|
+
value.each do |k, v|
|
229
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
else # model
|
233
|
+
# models (e.g. Pet) or oneOf
|
234
|
+
klass = Coinbase::Client.const_get(type)
|
235
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns the string representation of the object
|
240
|
+
# @return [String] String presentation of the object
|
241
|
+
def to_s
|
242
|
+
to_hash.to_s
|
243
|
+
end
|
244
|
+
|
245
|
+
# to_body is an alias to to_hash (backward compatibility)
|
246
|
+
# @return [Hash] Returns the object in the form of hash
|
247
|
+
def to_body
|
248
|
+
to_hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Returns the object in the form of hash
|
252
|
+
# @return [Hash] Returns the object in the form of hash
|
253
|
+
def to_hash
|
254
|
+
hash = {}
|
255
|
+
self.class.attribute_map.each_pair do |attr, param|
|
256
|
+
value = self.send(attr)
|
257
|
+
if value.nil?
|
258
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
259
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
260
|
+
end
|
261
|
+
|
262
|
+
hash[param] = _to_hash(value)
|
263
|
+
end
|
264
|
+
hash
|
265
|
+
end
|
266
|
+
|
267
|
+
# Outputs non-array value in the form of hash
|
268
|
+
# For object, use to_hash. Otherwise, just return the value
|
269
|
+
# @param [Object] value Any valid value
|
270
|
+
# @return [Hash] Returns the value in the form of hash
|
271
|
+
def _to_hash(value)
|
272
|
+
if value.is_a?(Array)
|
273
|
+
value.compact.map { |v| _to_hash(v) }
|
274
|
+
elsif value.is_a?(Hash)
|
275
|
+
{}.tap do |hash|
|
276
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
277
|
+
end
|
278
|
+
elsif value.respond_to? :to_hash
|
279
|
+
value.to_hash
|
280
|
+
else
|
281
|
+
value
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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
|
+
class TokenTransferType
|
18
|
+
ERC20 = "erc20".freeze
|
19
|
+
ERC721 = "erc721".freeze
|
20
|
+
ERC1155 = "erc1155".freeze
|
21
|
+
UNKNOWN = "unknown".freeze
|
22
|
+
UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
|
23
|
+
|
24
|
+
def self.all_vars
|
25
|
+
@all_vars ||= [ERC20, ERC721, ERC1155, UNKNOWN, UNKNOWN_DEFAULT_OPEN_API].freeze
|
26
|
+
end
|
27
|
+
|
28
|
+
# Builds the enum from string
|
29
|
+
# @param [String] The enum value in the form of the string
|
30
|
+
# @return [String] The enum value
|
31
|
+
def self.build_from_hash(value)
|
32
|
+
new.build_from_hash(value)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Builds the enum from string
|
36
|
+
# @param [String] The enum value in the form of the string
|
37
|
+
# @return [String] The enum value
|
38
|
+
def build_from_hash(value)
|
39
|
+
return value if TokenTransferType.all_vars.include?(value)
|
40
|
+
raise "Invalid ENUM value #{value} for class #TokenTransferType"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -79,8 +79,6 @@ module Coinbase::Client
|
|
79
79
|
|
80
80
|
if attributes.key?(:'notification_uri')
|
81
81
|
self.notification_uri = attributes[:'notification_uri']
|
82
|
-
else
|
83
|
-
self.notification_uri = nil
|
84
82
|
end
|
85
83
|
end
|
86
84
|
|
@@ -89,10 +87,6 @@ module Coinbase::Client
|
|
89
87
|
def list_invalid_properties
|
90
88
|
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
91
89
|
invalid_properties = Array.new
|
92
|
-
if @notification_uri.nil?
|
93
|
-
invalid_properties.push('invalid value for "notification_uri", notification_uri cannot be nil.')
|
94
|
-
end
|
95
|
-
|
96
90
|
invalid_properties
|
97
91
|
end
|
98
92
|
|
@@ -100,7 +94,6 @@ module Coinbase::Client
|
|
100
94
|
# @return true if the model is valid
|
101
95
|
def valid?
|
102
96
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
103
|
-
return false if @notification_uri.nil?
|
104
97
|
true
|
105
98
|
end
|
106
99
|
|
data/lib/coinbase/client.rb
CHANGED
@@ -35,6 +35,8 @@ Coinbase::Client.autoload :ContractInvocation, 'coinbase/client/models/contract_
|
|
35
35
|
Coinbase::Client.autoload :ContractInvocationList, 'coinbase/client/models/contract_invocation_list'
|
36
36
|
Coinbase::Client.autoload :CreateAddressRequest, 'coinbase/client/models/create_address_request'
|
37
37
|
Coinbase::Client.autoload :CreateContractInvocationRequest, 'coinbase/client/models/create_contract_invocation_request'
|
38
|
+
Coinbase::Client.autoload :CreateFundOperationRequest, 'coinbase/client/models/create_fund_operation_request'
|
39
|
+
Coinbase::Client.autoload :CreateFundQuoteRequest, 'coinbase/client/models/create_fund_quote_request'
|
38
40
|
Coinbase::Client.autoload :CreatePayloadSignatureRequest, 'coinbase/client/models/create_payload_signature_request'
|
39
41
|
Coinbase::Client.autoload :CreateServerSignerRequest, 'coinbase/client/models/create_server_signer_request'
|
40
42
|
Coinbase::Client.autoload :CreateSmartContractRequest, 'coinbase/client/models/create_smart_contract_request'
|
@@ -43,11 +45,14 @@ Coinbase::Client.autoload :CreateTradeRequest, 'coinbase/client/models/create_tr
|
|
43
45
|
Coinbase::Client.autoload :CreateTransferRequest, 'coinbase/client/models/create_transfer_request'
|
44
46
|
Coinbase::Client.autoload :CreateWalletRequest, 'coinbase/client/models/create_wallet_request'
|
45
47
|
Coinbase::Client.autoload :CreateWalletRequestWallet, 'coinbase/client/models/create_wallet_request_wallet'
|
48
|
+
Coinbase::Client.autoload :CreateWalletWebhookRequest, 'coinbase/client/models/create_wallet_webhook_request'
|
46
49
|
Coinbase::Client.autoload :CreateWebhookRequest, 'coinbase/client/models/create_webhook_request'
|
50
|
+
Coinbase::Client.autoload :CryptoAmount, 'coinbase/client/models/crypto_amount'
|
47
51
|
Coinbase::Client.autoload :DeploySmartContractRequest, 'coinbase/client/models/deploy_smart_contract_request'
|
48
52
|
Coinbase::Client.autoload :ERC20TransferEvent, 'coinbase/client/models/erc20_transfer_event'
|
49
53
|
Coinbase::Client.autoload :ERC721TransferEvent, 'coinbase/client/models/erc721_transfer_event'
|
50
54
|
Coinbase::Client.autoload :Error, 'coinbase/client/models/error'
|
55
|
+
Coinbase::Client.autoload :EthereumTokenTransfer, 'coinbase/client/models/ethereum_token_transfer'
|
51
56
|
Coinbase::Client.autoload :EthereumTransaction, 'coinbase/client/models/ethereum_transaction'
|
52
57
|
Coinbase::Client.autoload :EthereumTransactionAccess, 'coinbase/client/models/ethereum_transaction_access'
|
53
58
|
Coinbase::Client.autoload :EthereumTransactionAccessList, 'coinbase/client/models/ethereum_transaction_access_list'
|
@@ -58,14 +63,22 @@ Coinbase::Client.autoload :FeatureSet, 'coinbase/client/models/feature_set'
|
|
58
63
|
Coinbase::Client.autoload :FetchHistoricalStakingBalances200Response, 'coinbase/client/models/fetch_historical_staking_balances200_response'
|
59
64
|
Coinbase::Client.autoload :FetchStakingRewards200Response, 'coinbase/client/models/fetch_staking_rewards200_response'
|
60
65
|
Coinbase::Client.autoload :FetchStakingRewardsRequest, 'coinbase/client/models/fetch_staking_rewards_request'
|
66
|
+
Coinbase::Client.autoload :FiatAmount, 'coinbase/client/models/fiat_amount'
|
67
|
+
Coinbase::Client.autoload :FundOperation, 'coinbase/client/models/fund_operation'
|
68
|
+
Coinbase::Client.autoload :FundOperationFees, 'coinbase/client/models/fund_operation_fees'
|
69
|
+
Coinbase::Client.autoload :FundOperationList, 'coinbase/client/models/fund_operation_list'
|
70
|
+
Coinbase::Client.autoload :FundQuote, 'coinbase/client/models/fund_quote'
|
61
71
|
Coinbase::Client.autoload :GetStakingContextRequest, 'coinbase/client/models/get_staking_context_request'
|
62
72
|
Coinbase::Client.autoload :HistoricalBalance, 'coinbase/client/models/historical_balance'
|
63
73
|
Coinbase::Client.autoload :MultiTokenContractOptions, 'coinbase/client/models/multi_token_contract_options'
|
64
74
|
Coinbase::Client.autoload :NFTContractOptions, 'coinbase/client/models/nft_contract_options'
|
65
75
|
Coinbase::Client.autoload :Network, 'coinbase/client/models/network'
|
66
76
|
Coinbase::Client.autoload :NetworkIdentifier, 'coinbase/client/models/network_identifier'
|
77
|
+
Coinbase::Client.autoload :OnchainName, 'coinbase/client/models/onchain_name'
|
78
|
+
Coinbase::Client.autoload :OnchainNameList, 'coinbase/client/models/onchain_name_list'
|
67
79
|
Coinbase::Client.autoload :PayloadSignature, 'coinbase/client/models/payload_signature'
|
68
80
|
Coinbase::Client.autoload :PayloadSignatureList, 'coinbase/client/models/payload_signature_list'
|
81
|
+
Coinbase::Client.autoload :ReadContractRequest, 'coinbase/client/models/read_contract_request'
|
69
82
|
Coinbase::Client.autoload :SeedCreationEvent, 'coinbase/client/models/seed_creation_event'
|
70
83
|
Coinbase::Client.autoload :SeedCreationEventResult, 'coinbase/client/models/seed_creation_event_result'
|
71
84
|
Coinbase::Client.autoload :ServerSigner, 'coinbase/client/models/server_signer'
|
@@ -80,6 +93,7 @@ Coinbase::Client.autoload :SmartContract, 'coinbase/client/models/smart_contract
|
|
80
93
|
Coinbase::Client.autoload :SmartContractList, 'coinbase/client/models/smart_contract_list'
|
81
94
|
Coinbase::Client.autoload :SmartContractOptions, 'coinbase/client/models/smart_contract_options'
|
82
95
|
Coinbase::Client.autoload :SmartContractType, 'coinbase/client/models/smart_contract_type'
|
96
|
+
Coinbase::Client.autoload :SolidityValue, 'coinbase/client/models/solidity_value'
|
83
97
|
Coinbase::Client.autoload :SponsoredSend, 'coinbase/client/models/sponsored_send'
|
84
98
|
Coinbase::Client.autoload :StakingBalance, 'coinbase/client/models/staking_balance'
|
85
99
|
Coinbase::Client.autoload :StakingContext, 'coinbase/client/models/staking_context'
|
@@ -90,6 +104,7 @@ Coinbase::Client.autoload :StakingReward, 'coinbase/client/models/staking_reward
|
|
90
104
|
Coinbase::Client.autoload :StakingRewardFormat, 'coinbase/client/models/staking_reward_format'
|
91
105
|
Coinbase::Client.autoload :StakingRewardUSDValue, 'coinbase/client/models/staking_reward_usd_value'
|
92
106
|
Coinbase::Client.autoload :TokenContractOptions, 'coinbase/client/models/token_contract_options'
|
107
|
+
Coinbase::Client.autoload :TokenTransferType, 'coinbase/client/models/token_transfer_type'
|
93
108
|
Coinbase::Client.autoload :Trade, 'coinbase/client/models/trade'
|
94
109
|
Coinbase::Client.autoload :TradeList, 'coinbase/client/models/trade_list'
|
95
110
|
Coinbase::Client.autoload :Transaction, 'coinbase/client/models/transaction'
|
@@ -119,7 +134,9 @@ Coinbase::Client.autoload :BalanceHistoryApi, 'coinbase/client/api/balance_histo
|
|
119
134
|
Coinbase::Client.autoload :ContractEventsApi, 'coinbase/client/api/contract_events_api'
|
120
135
|
Coinbase::Client.autoload :ContractInvocationsApi, 'coinbase/client/api/contract_invocations_api'
|
121
136
|
Coinbase::Client.autoload :ExternalAddressesApi, 'coinbase/client/api/external_addresses_api'
|
137
|
+
Coinbase::Client.autoload :FundApi, 'coinbase/client/api/fund_api'
|
122
138
|
Coinbase::Client.autoload :NetworksApi, 'coinbase/client/api/networks_api'
|
139
|
+
Coinbase::Client.autoload :OnchainIdentityApi, 'coinbase/client/api/onchain_identity_api'
|
123
140
|
Coinbase::Client.autoload :ServerSignersApi, 'coinbase/client/api/server_signers_api'
|
124
141
|
Coinbase::Client.autoload :SmartContractsApi, 'coinbase/client/api/smart_contracts_api'
|
125
142
|
Coinbase::Client.autoload :StakeApi, 'coinbase/client/api/stake_api'
|
@@ -12,22 +12,80 @@ module Coinbase
|
|
12
12
|
@model = model
|
13
13
|
end
|
14
14
|
|
15
|
+
# Returns the Faucet transaction.
|
16
|
+
# @return [Coinbase::Transaction] The Faucet transaction
|
17
|
+
def transaction
|
18
|
+
@transaction ||= Coinbase::Transaction.new(@model.transaction)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the status of the Faucet transaction.
|
22
|
+
# @return [Symbol] The status
|
23
|
+
def status
|
24
|
+
transaction.status
|
25
|
+
end
|
26
|
+
|
15
27
|
# Returns the transaction hash.
|
16
28
|
# @return [String] The onchain transaction hash
|
17
29
|
def transaction_hash
|
18
|
-
|
30
|
+
transaction.transaction_hash
|
19
31
|
end
|
20
32
|
|
21
33
|
# Returns the link to the transaction on the blockchain explorer.
|
22
34
|
# @return [String] The link to the transaction on the blockchain explorer
|
23
35
|
def transaction_link
|
24
|
-
|
36
|
+
transaction.transaction_link
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the Network of the Transaction.
|
40
|
+
# @return [Coinbase::Network] The Network
|
41
|
+
def network
|
42
|
+
transaction.network
|
43
|
+
end
|
44
|
+
|
45
|
+
# Waits until the FaucetTransaction is completed or failed by polling on the given interval.
|
46
|
+
# @param interval_seconds [Integer] The interval at which to poll the Network, in seconds
|
47
|
+
# @param timeout_seconds [Integer] The maximum amount of time to wait for the Transfer to complete, in seconds
|
48
|
+
# @raise [Timeout::Error] if the FaucetTransaction takes longer than the given timeout
|
49
|
+
# @return [Transfer] The completed Transfer object
|
50
|
+
def wait!(interval_seconds = 0.2, timeout_seconds = 20)
|
51
|
+
start_time = Time.now
|
52
|
+
|
53
|
+
loop do
|
54
|
+
reload
|
55
|
+
|
56
|
+
return self if transaction.terminal_state?
|
57
|
+
|
58
|
+
raise Timeout::Error, 'Faucet transaction timed out' if Time.now - start_time > timeout_seconds
|
59
|
+
|
60
|
+
self.sleep interval_seconds
|
61
|
+
end
|
62
|
+
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def reload
|
67
|
+
@model = Coinbase.call_api do
|
68
|
+
addresses_api.get_faucet_transaction(
|
69
|
+
network.normalized_id,
|
70
|
+
transaction.to_address_id,
|
71
|
+
transaction_hash
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
@transaction = Coinbase::Transaction.new(@model.transaction)
|
76
|
+
|
77
|
+
self
|
25
78
|
end
|
26
79
|
|
27
80
|
# Returns a String representation of the FaucetTransaction.
|
28
81
|
# @return [String] a String representation of the FaucetTransaction
|
29
82
|
def to_s
|
30
|
-
|
83
|
+
Coinbase.pretty_print_object(
|
84
|
+
self.class,
|
85
|
+
status: transaction.status,
|
86
|
+
transaction_hash: transaction_hash,
|
87
|
+
transaction_link: transaction_link
|
88
|
+
)
|
31
89
|
end
|
32
90
|
|
33
91
|
# Same as to_s.
|
@@ -38,6 +96,8 @@ module Coinbase
|
|
38
96
|
|
39
97
|
private
|
40
98
|
|
41
|
-
|
99
|
+
def addresses_api
|
100
|
+
@addresses_api ||= Coinbase::Client::ExternalAddressesApi.new(Coinbase.configuration.api_client)
|
101
|
+
end
|
42
102
|
end
|
43
103
|
end
|
@@ -105,6 +105,12 @@ module Coinbase
|
|
105
105
|
new(contract)
|
106
106
|
end
|
107
107
|
|
108
|
+
# Creates a new ERC1155 multi-token contract, that can subsequently be deployed to
|
109
|
+
# the blockchain.
|
110
|
+
# @param address_id [String] The address ID of deployer
|
111
|
+
# @param wallet_id [String] The wallet ID of the deployer
|
112
|
+
# @param uri [String] The URI for the token metadata
|
113
|
+
# @return [SmartContract] The new ERC1155 Multi-Token SmartContract object
|
108
114
|
def self.create_multi_token_contract(
|
109
115
|
address_id:,
|
110
116
|
wallet_id:,
|
@@ -126,6 +132,95 @@ module Coinbase
|
|
126
132
|
new(contract)
|
127
133
|
end
|
128
134
|
|
135
|
+
# Reads data from a deployed smart contract.
|
136
|
+
#
|
137
|
+
# @param network [Coinbase::Network, Symbol] The Network or Network ID of the Asset
|
138
|
+
# @param contract_address [String] The address of the deployed contract
|
139
|
+
# @param method [String] The name of the method to call on the contract
|
140
|
+
# @param abi [Array, nil] The ABI of the contract. If nil, the method will attempt to use a cached ABI
|
141
|
+
# @param args [Hash] The arguments to pass to the contract method.
|
142
|
+
# The keys should be the argument names, and the values should be the argument values.
|
143
|
+
# @return [Object] The result of the contract call, converted to an appropriate Ruby type
|
144
|
+
# @raise [Coinbase::ApiError] If there's an error in the API call
|
145
|
+
def self.read(
|
146
|
+
network:,
|
147
|
+
contract_address:,
|
148
|
+
method:,
|
149
|
+
abi: nil,
|
150
|
+
args: {}
|
151
|
+
)
|
152
|
+
network = Coinbase::Network.from_id(network)
|
153
|
+
|
154
|
+
response = Coinbase.call_api do
|
155
|
+
smart_contracts_api.read_contract(
|
156
|
+
network.normalized_id,
|
157
|
+
contract_address,
|
158
|
+
{
|
159
|
+
method: method,
|
160
|
+
args: (args || {}).to_json,
|
161
|
+
abi: abi&.to_json
|
162
|
+
}
|
163
|
+
)
|
164
|
+
end
|
165
|
+
|
166
|
+
convert_solidity_value(response)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Converts a Solidity value to an appropriate Ruby type.
|
170
|
+
#
|
171
|
+
# @param solidity_value [Coinbase::Client::SolidityValue] The Solidity value to convert
|
172
|
+
# @return [Object] The converted Ruby value
|
173
|
+
# @raise [ArgumentError] If an unsupported Solidity type is encountered
|
174
|
+
#
|
175
|
+
# This method handles the following Solidity types:
|
176
|
+
# - Integers (uint8, uint16, uint32, uint64, uint128, uint256, int8, int16, int32, int64, int128, int256)
|
177
|
+
# - Address
|
178
|
+
# - String
|
179
|
+
# - Bytes (including fixed-size byte arrays)
|
180
|
+
# - Boolean
|
181
|
+
# - Array
|
182
|
+
# - Tuple (converted to a Hash)
|
183
|
+
#
|
184
|
+
# For complex types like arrays and tuples, the method recursively converts nested values.
|
185
|
+
def self.convert_solidity_value(solidity_value)
|
186
|
+
return nil if solidity_value.nil?
|
187
|
+
|
188
|
+
type = solidity_value.type
|
189
|
+
value = solidity_value.value
|
190
|
+
values = solidity_value.values
|
191
|
+
|
192
|
+
case type
|
193
|
+
when 'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256',
|
194
|
+
'int8', 'int16', 'int32', 'int64', 'int128', 'int256'
|
195
|
+
value&.to_i
|
196
|
+
when 'address', 'string', /^bytes/
|
197
|
+
value
|
198
|
+
when 'bool'
|
199
|
+
if value.is_a?(String)
|
200
|
+
value == 'true'
|
201
|
+
else
|
202
|
+
!value.nil?
|
203
|
+
end
|
204
|
+
when 'array'
|
205
|
+
values ? values.map { |v| convert_solidity_value(v) } : []
|
206
|
+
when 'tuple'
|
207
|
+
if values
|
208
|
+
result = {}
|
209
|
+
values.each do |v|
|
210
|
+
raise ArgumentError, 'Error: Tuple value without a name' unless v.respond_to?(:name)
|
211
|
+
|
212
|
+
result[v.name] = convert_solidity_value(v)
|
213
|
+
end
|
214
|
+
result
|
215
|
+
else
|
216
|
+
{}
|
217
|
+
end
|
218
|
+
else
|
219
|
+
raise ArgumentError, "Unsupported Solidity type: #{type}"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
private_class_method :convert_solidity_value
|
223
|
+
|
129
224
|
def self.contract_events_api
|
130
225
|
Coinbase::Client::ContractEventsApi.new(Coinbase.configuration.api_client)
|
131
226
|
end
|
data/lib/coinbase/transaction.rb
CHANGED
@@ -41,6 +41,12 @@ module Coinbase
|
|
41
41
|
@model = model
|
42
42
|
end
|
43
43
|
|
44
|
+
# Returns the Network of the Transaction.
|
45
|
+
# @return [Coinbase::Network] The Network
|
46
|
+
def network
|
47
|
+
@network ||= Coinbase::Network.from_id(@model.network_id)
|
48
|
+
end
|
49
|
+
|
44
50
|
# Returns the Unsigned Payload of the Transaction.
|
45
51
|
# @return [String] The Unsigned Payload
|
46
52
|
def unsigned_payload
|
@@ -101,8 +107,8 @@ module Coinbase
|
|
101
107
|
@model.transaction_link
|
102
108
|
end
|
103
109
|
|
104
|
-
# Returns
|
105
|
-
# @return [
|
110
|
+
# Returns detailed content the Transaction.
|
111
|
+
# @return [EthereumTransaction] The transaction content
|
106
112
|
def content
|
107
113
|
@model.content
|
108
114
|
end
|
data/lib/coinbase/version.rb
CHANGED