From 1ee08829c9ecd6f53b40b7cfdcadcd52693eb5d3 Mon Sep 17 00:00:00 2001 From: Alexander Stone Date: Tue, 17 Dec 2024 13:39:46 -0800 Subject: [PATCH 1/4] feat: Add address reputation (#221) ### What changed? Why? This adds support for fetching an address' reputation lazily. Example: ```ruby risky_address = Coinbase::ExternalAddress.new(:ethereum_mainnet, '0x12846c6Fd6baBFE4bC6F761eB871eFfFDEb26913') # Returns the reputation of the address risky_address.reputation => Coinbase::AddressReputation{score: '-90', total_transactions: '0', unique_days_active: '0', longest_active_streak: '0', current_active_streak: '0', activity_period_days: '0', token_swaps_performed: '0', bridge_transactions_performed: '0', lend_borrow_stake_transactions: '0', ens_contract_interactions: '0', smart_contract_deployments: '0'} # Returns whether the address itself is deemed "risky" risky_address.risky? => true ``` #### Qualified Impact --------- Co-authored-by: arpit-srivastava --- CHANGELOG.md | 5 + lib/coinbase.rb | 3 +- lib/coinbase/address.rb | 25 +- lib/coinbase/address_reputation.rb | 67 +++ lib/coinbase/client.rb | 4 +- lib/coinbase/client/api/reputation_api.rb | 69 ---- .../client/api/smart_contracts_api.rb | 107 ++++- .../client/models/address_reputation.rb | 23 +- .../client/models/ethereum_transaction.rb | 18 +- .../models/register_smart_contract_request.rb | 240 +++++++++++ lib/coinbase/client/models/smart_contract.rb | 66 +-- .../models/smart_contract_activity_event.rb | 386 ++++++++++++++++++ .../client/models/smart_contract_type.rb | 3 +- .../client/models/webhook_event_type.rb | 3 +- .../models/webhook_event_type_filter.rb | 1 + ...=> webhook_smart_contract_event_filter.rb} | 34 +- .../models/webhook_wallet_activity_filter.rb | 7 + spec/factories/address_reputation.rb | 39 ++ spec/spec_helper.rb | 1 + .../shared_examples/address_reputation.rb | 31 ++ .../coinbase/address/external_address_spec.rb | 1 + .../coinbase/address/wallet_address_spec.rb | 1 + spec/unit/coinbase/address_reputation_spec.rb | 94 +++++ spec/unit/coinbase/address_spec.rb | 16 + 24 files changed, 1090 insertions(+), 154 deletions(-) create mode 100644 lib/coinbase/address_reputation.rb create mode 100644 lib/coinbase/client/models/register_smart_contract_request.rb create mode 100644 lib/coinbase/client/models/smart_contract_activity_event.rb rename lib/coinbase/client/models/{address_risk.rb => webhook_smart_contract_event_filter.rb} (84%) create mode 100644 spec/factories/address_reputation.rb create mode 100644 spec/support/shared_examples/address_reputation.rb create mode 100644 spec/unit/coinbase/address_reputation_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 861dbcfd..a9643f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +* Add support for fetching address reputation. + +## [0.12.0] - Skipped + ## [0.11.0] - 2024-11-27 ### Added diff --git a/lib/coinbase.rb b/lib/coinbase.rb index 559695a0..a3472c87 100644 --- a/lib/coinbase.rb +++ b/lib/coinbase.rb @@ -1,15 +1,16 @@ # frozen_string_literal: true +require_relative 'coinbase/client' require_relative 'coinbase/address' require_relative 'coinbase/address/wallet_address' require_relative 'coinbase/address/external_address' +require_relative 'coinbase/address_reputation' require_relative 'coinbase/asset' require_relative 'coinbase/authenticator' require_relative 'coinbase/correlation' require_relative 'coinbase/balance' require_relative 'coinbase/balance_map' require_relative 'coinbase/historical_balance' -require_relative 'coinbase/client' require_relative 'coinbase/constants' require_relative 'coinbase/contract_event' require_relative 'coinbase/contract_invocation' diff --git a/lib/coinbase/address.rb b/lib/coinbase/address.rb index d5837abd..552ed122 100644 --- a/lib/coinbase/address.rb +++ b/lib/coinbase/address.rb @@ -17,7 +17,14 @@ def initialize(network, id) # Returns a String representation of the Address. # @return [String] a String representation of the Address def to_s - Coinbase.pretty_print_object(self.class, id: id, network_id: network.id) + Coinbase.pretty_print_object( + self.class, + **{ + id: id, + network_id: network.id, + reputation_score: @reputation.nil? ? nil : reputation.score + }.compact + ) end # Same as to_s. @@ -32,6 +39,18 @@ def can_sign? false end + # Returns the reputation of the Address. + # @return [Coinbase::AddressReputation] The reputation of the Address + def reputation + @reputation ||= Coinbase::AddressReputation.fetch(network: network, address_id: id) + end + + # Returns wheth the Address's reputation is risky. + # @return [Boolean] true if the Address's reputation is risky + def risky? + reputation.risky? + end + # Returns the balances of the Address. # @return [BalanceMap] The balances of the Address, keyed by asset ID. Ether balances are denominated # in ETH. @@ -66,7 +85,7 @@ def balance(asset_id) # @return [Enumerable] Enumerator that returns historical_balance def historical_balances(asset_id) Coinbase::Pagination.enumerate( - ->(page) { list_page(asset_id, page) } + ->(page) { list_historical_balance_page(asset_id, page) } ) do |historical_balance| Coinbase::HistoricalBalance.from_model(historical_balance) end @@ -265,7 +284,7 @@ def stake_api @stake_api ||= Coinbase::Client::StakeApi.new(Coinbase.configuration.api_client) end - def list_page(asset_id, page) + def list_historical_balance_page(asset_id, page) balance_history_api.list_address_historical_balance( network.normalized_id, id, diff --git a/lib/coinbase/address_reputation.rb b/lib/coinbase/address_reputation.rb new file mode 100644 index 00000000..7e8b7e69 --- /dev/null +++ b/lib/coinbase/address_reputation.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +module Coinbase + # A representation of the reputation of a blockchain address. + class AddressReputation + # A metadata object associated with an address reputation. + Metadata = Struct.new( + *Client::AddressReputationMetadata.attribute_map.keys.map(&:to_sym), + keyword_init: true + ) do + def to_s + Coinbase.pretty_print_object( + self.class, + **to_h + ) + end + end + + class << self + def fetch(address_id:, network: Coinbase.default_network) + network = Coinbase::Network.from_id(network) + + model = Coinbase.call_api do + reputation_api.get_address_reputation(network.normalized_id, address_id) + end + + new(model) + end + + private + + def reputation_api + Coinbase::Client::ReputationApi.new(Coinbase.configuration.api_client) + end + end + + def initialize(model) + raise ArgumentError, 'must be an AddressReputation object' unless model.is_a?(Coinbase::Client::AddressReputation) + + @model = model + end + + def score + @model.score + end + + def metadata + @metadata ||= Metadata.new(**@model.metadata) + end + + def risky? + score.negative? + end + + def to_s + Coinbase.pretty_print_object( + self.class, + score: score, + **metadata.to_h + ) + end + + def inspect + to_s + end + end +end diff --git a/lib/coinbase/client.rb b/lib/coinbase/client.rb index d0a11450..04f31ee7 100644 --- a/lib/coinbase/client.rb +++ b/lib/coinbase/client.rb @@ -23,7 +23,6 @@ Coinbase::Client.autoload :AddressList, 'coinbase/client/models/address_list' Coinbase::Client.autoload :AddressReputation, 'coinbase/client/models/address_reputation' Coinbase::Client.autoload :AddressReputationMetadata, 'coinbase/client/models/address_reputation_metadata' -Coinbase::Client.autoload :AddressRisk, 'coinbase/client/models/address_risk' Coinbase::Client.autoload :AddressTransactionList, 'coinbase/client/models/address_transaction_list' Coinbase::Client.autoload :Asset, 'coinbase/client/models/asset' Coinbase::Client.autoload :Balance, 'coinbase/client/models/balance' @@ -82,6 +81,7 @@ Coinbase::Client.autoload :PayloadSignature, 'coinbase/client/models/payload_signature' Coinbase::Client.autoload :PayloadSignatureList, 'coinbase/client/models/payload_signature_list' Coinbase::Client.autoload :ReadContractRequest, 'coinbase/client/models/read_contract_request' +Coinbase::Client.autoload :RegisterSmartContractRequest, 'coinbase/client/models/register_smart_contract_request' Coinbase::Client.autoload :SeedCreationEvent, 'coinbase/client/models/seed_creation_event' Coinbase::Client.autoload :SeedCreationEventResult, 'coinbase/client/models/seed_creation_event_result' Coinbase::Client.autoload :ServerSigner, 'coinbase/client/models/server_signer' @@ -93,6 +93,7 @@ Coinbase::Client.autoload :SignatureCreationEventResult, 'coinbase/client/models/signature_creation_event_result' Coinbase::Client.autoload :SignedVoluntaryExitMessageMetadata, 'coinbase/client/models/signed_voluntary_exit_message_metadata' Coinbase::Client.autoload :SmartContract, 'coinbase/client/models/smart_contract' +Coinbase::Client.autoload :SmartContractActivityEvent, 'coinbase/client/models/smart_contract_activity_event' Coinbase::Client.autoload :SmartContractList, 'coinbase/client/models/smart_contract_list' Coinbase::Client.autoload :SmartContractOptions, 'coinbase/client/models/smart_contract_options' Coinbase::Client.autoload :SmartContractType, 'coinbase/client/models/smart_contract_type' @@ -128,6 +129,7 @@ Coinbase::Client.autoload :WebhookEventType, 'coinbase/client/models/webhook_event_type' Coinbase::Client.autoload :WebhookEventTypeFilter, 'coinbase/client/models/webhook_event_type_filter' Coinbase::Client.autoload :WebhookList, 'coinbase/client/models/webhook_list' +Coinbase::Client.autoload :WebhookSmartContractEventFilter, 'coinbase/client/models/webhook_smart_contract_event_filter' Coinbase::Client.autoload :WebhookWalletActivityFilter, 'coinbase/client/models/webhook_wallet_activity_filter' # APIs diff --git a/lib/coinbase/client/api/reputation_api.rb b/lib/coinbase/client/api/reputation_api.rb index 748f13a2..c88936d8 100644 --- a/lib/coinbase/client/api/reputation_api.rb +++ b/lib/coinbase/client/api/reputation_api.rb @@ -87,74 +87,5 @@ def get_address_reputation_with_http_info(network_id, address_id, opts = {}) end return data, status_code, headers end - - # Get the risk of an address - # Get the risk of an address - # @param network_id [String] The ID of the blockchain network. - # @param address_id [String] The ID of the address to fetch the risk for. - # @param [Hash] opts the optional parameters - # @return [AddressRisk] - def get_address_risk(network_id, address_id, opts = {}) - data, _status_code, _headers = get_address_risk_with_http_info(network_id, address_id, opts) - data - end - - # Get the risk of an address - # Get the risk of an address - # @param network_id [String] The ID of the blockchain network. - # @param address_id [String] The ID of the address to fetch the risk for. - # @param [Hash] opts the optional parameters - # @return [Array<(AddressRisk, Integer, Hash)>] AddressRisk data, response status code and response headers - def get_address_risk_with_http_info(network_id, address_id, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ReputationApi.get_address_risk ...' - end - # verify the required parameter 'network_id' is set - if @api_client.config.client_side_validation && network_id.nil? - fail ArgumentError, "Missing the required parameter 'network_id' when calling ReputationApi.get_address_risk" - end - # verify the required parameter 'address_id' is set - if @api_client.config.client_side_validation && address_id.nil? - fail ArgumentError, "Missing the required parameter 'address_id' when calling ReputationApi.get_address_risk" - end - # resource path - local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/risk'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)) - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] - - # form parameters - form_params = opts[:form_params] || {} - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'AddressRisk' - - # auth_names - auth_names = opts[:debug_auth_names] || [] - - new_options = opts.merge( - :operation => :"ReputationApi.get_address_risk", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: ReputationApi#get_address_risk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end end end diff --git a/lib/coinbase/client/api/smart_contracts_api.rb b/lib/coinbase/client/api/smart_contracts_api.rb index b5bbba7d..e6e5f6b3 100644 --- a/lib/coinbase/client/api/smart_contracts_api.rb +++ b/lib/coinbase/client/api/smart_contracts_api.rb @@ -260,40 +260,31 @@ def get_smart_contract_with_http_info(wallet_id, address_id, smart_contract_id, return data, status_code, headers end - # List smart contracts deployed by address - # List all smart contracts deployed by address. - # @param wallet_id [String] The ID of the wallet the address belongs to. - # @param address_id [String] The ID of the address to fetch the smart contracts for. + # List smart contracts + # List smart contracts # @param [Hash] opts the optional parameters + # @option opts [String] :page Pagination token for retrieving the next set of results # @return [SmartContractList] - def list_smart_contracts(wallet_id, address_id, opts = {}) - data, _status_code, _headers = list_smart_contracts_with_http_info(wallet_id, address_id, opts) + def list_smart_contracts(opts = {}) + data, _status_code, _headers = list_smart_contracts_with_http_info(opts) data end - # List smart contracts deployed by address - # List all smart contracts deployed by address. - # @param wallet_id [String] The ID of the wallet the address belongs to. - # @param address_id [String] The ID of the address to fetch the smart contracts for. + # List smart contracts + # List smart contracts # @param [Hash] opts the optional parameters + # @option opts [String] :page Pagination token for retrieving the next set of results # @return [Array<(SmartContractList, Integer, Hash)>] SmartContractList data, response status code and response headers - def list_smart_contracts_with_http_info(wallet_id, address_id, opts = {}) + def list_smart_contracts_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SmartContractsApi.list_smart_contracts ...' end - # verify the required parameter 'wallet_id' is set - if @api_client.config.client_side_validation && wallet_id.nil? - fail ArgumentError, "Missing the required parameter 'wallet_id' when calling SmartContractsApi.list_smart_contracts" - end - # verify the required parameter 'address_id' is set - if @api_client.config.client_side_validation && address_id.nil? - fail ArgumentError, "Missing the required parameter 'address_id' when calling SmartContractsApi.list_smart_contracts" - end # resource path - local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/smart_contracts'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)) + local_var_path = '/v1/smart_contracts' # query parameters query_params = opts[:query_params] || {} + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? # header parameters header_params = opts[:header_params] || {} @@ -408,5 +399,81 @@ def read_contract_with_http_info(network_id, contract_address, read_contract_req end return data, status_code, headers end + + # Register a smart contract + # Register a smart contract + # @param network_id [String] The ID of the network to fetch. + # @param contract_address [String] EVM address of the smart contract (42 characters, including '0x', in lowercase) + # @param [Hash] opts the optional parameters + # @option opts [RegisterSmartContractRequest] :register_smart_contract_request + # @return [SmartContract] + def register_smart_contract(network_id, contract_address, opts = {}) + data, _status_code, _headers = register_smart_contract_with_http_info(network_id, contract_address, opts) + data + end + + # Register a smart contract + # Register a smart contract + # @param network_id [String] The ID of the network to fetch. + # @param contract_address [String] EVM address of the smart contract (42 characters, including '0x', in lowercase) + # @param [Hash] opts the optional parameters + # @option opts [RegisterSmartContractRequest] :register_smart_contract_request + # @return [Array<(SmartContract, Integer, Hash)>] SmartContract data, response status code and response headers + def register_smart_contract_with_http_info(network_id, contract_address, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SmartContractsApi.register_smart_contract ...' + end + # verify the required parameter 'network_id' is set + if @api_client.config.client_side_validation && network_id.nil? + fail ArgumentError, "Missing the required parameter 'network_id' when calling SmartContractsApi.register_smart_contract" + end + # verify the required parameter 'contract_address' is set + if @api_client.config.client_side_validation && contract_address.nil? + fail ArgumentError, "Missing the required parameter 'contract_address' when calling SmartContractsApi.register_smart_contract" + end + # resource path + local_var_path = '/v1/networks/{network_id}/smart_contracts/{contract_address}/register'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'contract_address' + '}', CGI.escape(contract_address.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'register_smart_contract_request']) + + # return_type + return_type = opts[:debug_return_type] || 'SmartContract' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"SmartContractsApi.register_smart_contract", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SmartContractsApi#register_smart_contract\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/coinbase/client/models/address_reputation.rb b/lib/coinbase/client/models/address_reputation.rb index a8a6b7de..6adb2ad1 100644 --- a/lib/coinbase/client/models/address_reputation.rb +++ b/lib/coinbase/client/models/address_reputation.rb @@ -16,15 +16,15 @@ module Coinbase::Client # The reputation score with metadata of a blockchain address. class AddressReputation - # The reputation score of a wallet address which lie between 0 to 100. - attr_accessor :reputation_score + # The score of a wallet address, ranging from -100 to 100. A negative score indicates a bad reputation, while a positive score indicates a good reputation. + attr_accessor :score attr_accessor :metadata # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'reputation_score' => :'reputation_score', + :'score' => :'score', :'metadata' => :'metadata' } end @@ -37,7 +37,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'reputation_score' => :'Integer', + :'score' => :'Integer', :'metadata' => :'AddressReputationMetadata' } end @@ -63,8 +63,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } - if attributes.key?(:'reputation_score') - self.reputation_score = attributes[:'reputation_score'] + if attributes.key?(:'score') + self.score = attributes[:'score'] + else + self.score = nil end if attributes.key?(:'metadata') @@ -79,6 +81,10 @@ def initialize(attributes = {}) def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new + if @score.nil? + invalid_properties.push('invalid value for "score", score cannot be nil.') + end + if @metadata.nil? invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') end @@ -90,6 +96,7 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @score.nil? return false if @metadata.nil? true end @@ -99,7 +106,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && - reputation_score == o.reputation_score && + score == o.score && metadata == o.metadata end @@ -112,7 +119,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [reputation_score, metadata].hash + [score, metadata].hash end # Builds the object from hash diff --git a/lib/coinbase/client/models/ethereum_transaction.rb b/lib/coinbase/client/models/ethereum_transaction.rb index d426fa76..2132eae1 100644 --- a/lib/coinbase/client/models/ethereum_transaction.rb +++ b/lib/coinbase/client/models/ethereum_transaction.rb @@ -66,6 +66,9 @@ class EthereumTransaction # This is for handling optimism rollup specific EIP-2718 transaction type field. attr_accessor :mint + # RLP encoded transaction as a hex string (prefixed with 0x) for native compatibility with popular eth clients such as etherjs, viem etc. + attr_accessor :rlp_encoded_tx + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -86,7 +89,8 @@ def self.attribute_map :'token_transfers' => :'token_transfers', :'flattened_traces' => :'flattened_traces', :'block_timestamp' => :'block_timestamp', - :'mint' => :'mint' + :'mint' => :'mint', + :'rlp_encoded_tx' => :'rlp_encoded_tx' } end @@ -115,7 +119,8 @@ def self.openapi_types :'token_transfers' => :'Array', :'flattened_traces' => :'Array', :'block_timestamp' => :'Time', - :'mint' => :'String' + :'mint' => :'String', + :'rlp_encoded_tx' => :'String' } end @@ -219,6 +224,10 @@ def initialize(attributes = {}) if attributes.key?(:'mint') self.mint = attributes[:'mint'] end + + if attributes.key?(:'rlp_encoded_tx') + self.rlp_encoded_tx = attributes[:'rlp_encoded_tx'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -268,7 +277,8 @@ def ==(o) token_transfers == o.token_transfers && flattened_traces == o.flattened_traces && block_timestamp == o.block_timestamp && - mint == o.mint + mint == o.mint && + rlp_encoded_tx == o.rlp_encoded_tx end # @see the `==` method @@ -280,7 +290,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [from, gas, gas_price, hash, input, nonce, to, index, value, type, max_fee_per_gas, max_priority_fee_per_gas, priority_fee_per_gas, transaction_access_list, token_transfers, flattened_traces, block_timestamp, mint].hash + [from, gas, gas_price, hash, input, nonce, to, index, value, type, max_fee_per_gas, max_priority_fee_per_gas, priority_fee_per_gas, transaction_access_list, token_transfers, flattened_traces, block_timestamp, mint, rlp_encoded_tx].hash end # Builds the object from hash diff --git a/lib/coinbase/client/models/register_smart_contract_request.rb b/lib/coinbase/client/models/register_smart_contract_request.rb new file mode 100644 index 00000000..73c9f7ca --- /dev/null +++ b/lib/coinbase/client/models/register_smart_contract_request.rb @@ -0,0 +1,240 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha + +Generated by: https://openapi-generator.tech +Generator version: 7.9.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # Smart Contract data to be registered + class RegisterSmartContractRequest + # ABI of the smart contract + attr_accessor :abi + + # Name of the smart contract + attr_accessor :contract_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'abi' => :'abi', + :'contract_name' => :'contract_name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'abi' => :'String', + :'contract_name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::RegisterSmartContractRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::RegisterSmartContractRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'abi') + self.abi = attributes[:'abi'] + else + self.abi = nil + end + + if attributes.key?(:'contract_name') + self.contract_name = attributes[:'contract_name'] + else + self.contract_name = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @abi.nil? + invalid_properties.push('invalid value for "abi", abi cannot be nil.') + end + + if @contract_name.nil? + invalid_properties.push('invalid value for "contract_name", contract_name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @abi.nil? + return false if @contract_name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + abi == o.abi && + contract_name == o.contract_name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [abi, contract_name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/smart_contract.rb b/lib/coinbase/client/models/smart_contract.rb index 9c8a3621..fac28e4e 100644 --- a/lib/coinbase/client/models/smart_contract.rb +++ b/lib/coinbase/client/models/smart_contract.rb @@ -16,19 +16,22 @@ module Coinbase::Client # Represents a smart contract on the blockchain class SmartContract - # The unique identifier of the smart contract + # The unique identifier of the smart contract. attr_accessor :smart_contract_id # The name of the blockchain network attr_accessor :network_id - # The ID of the wallet that deployed the smart contract + # The ID of the wallet that deployed the smart contract. If this smart contract was deployed externally, this will be omitted. attr_accessor :wallet_id # The EVM address of the smart contract attr_accessor :contract_address - # The EVM address of the account that deployed the smart contract + # The name of the smart contract + attr_accessor :contract_name + + # The EVM address of the account that deployed the smart contract. If this smart contract was deployed externally, this will be omitted. attr_accessor :deployer_address attr_accessor :type @@ -40,6 +43,9 @@ class SmartContract attr_accessor :transaction + # Whether the smart contract was deployed externally. If true, the deployer_address and transaction will be omitted. + attr_accessor :is_external + class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values @@ -69,11 +75,13 @@ def self.attribute_map :'network_id' => :'network_id', :'wallet_id' => :'wallet_id', :'contract_address' => :'contract_address', + :'contract_name' => :'contract_name', :'deployer_address' => :'deployer_address', :'type' => :'type', :'options' => :'options', :'abi' => :'abi', - :'transaction' => :'transaction' + :'transaction' => :'transaction', + :'is_external' => :'is_external' } end @@ -89,11 +97,13 @@ def self.openapi_types :'network_id' => :'String', :'wallet_id' => :'String', :'contract_address' => :'String', + :'contract_name' => :'String', :'deployer_address' => :'String', :'type' => :'SmartContractType', :'options' => :'SmartContractOptions', :'abi' => :'String', - :'transaction' => :'Transaction' + :'transaction' => :'Transaction', + :'is_external' => :'Boolean' } end @@ -132,8 +142,6 @@ def initialize(attributes = {}) if attributes.key?(:'wallet_id') self.wallet_id = attributes[:'wallet_id'] - else - self.wallet_id = nil end if attributes.key?(:'contract_address') @@ -142,10 +150,14 @@ def initialize(attributes = {}) self.contract_address = nil end + if attributes.key?(:'contract_name') + self.contract_name = attributes[:'contract_name'] + else + self.contract_name = nil + end + if attributes.key?(:'deployer_address') self.deployer_address = attributes[:'deployer_address'] - else - self.deployer_address = nil end if attributes.key?(:'type') @@ -156,8 +168,6 @@ def initialize(attributes = {}) if attributes.key?(:'options') self.options = attributes[:'options'] - else - self.options = nil end if attributes.key?(:'abi') @@ -168,8 +178,12 @@ def initialize(attributes = {}) if attributes.key?(:'transaction') self.transaction = attributes[:'transaction'] + end + + if attributes.key?(:'is_external') + self.is_external = attributes[:'is_external'] else - self.transaction = nil + self.is_external = nil end end @@ -186,32 +200,24 @@ def list_invalid_properties invalid_properties.push('invalid value for "network_id", network_id cannot be nil.') end - if @wallet_id.nil? - invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.') - end - if @contract_address.nil? invalid_properties.push('invalid value for "contract_address", contract_address cannot be nil.') end - if @deployer_address.nil? - invalid_properties.push('invalid value for "deployer_address", deployer_address cannot be nil.') + if @contract_name.nil? + invalid_properties.push('invalid value for "contract_name", contract_name cannot be nil.') end if @type.nil? invalid_properties.push('invalid value for "type", type cannot be nil.') end - if @options.nil? - invalid_properties.push('invalid value for "options", options cannot be nil.') - end - if @abi.nil? invalid_properties.push('invalid value for "abi", abi cannot be nil.') end - if @transaction.nil? - invalid_properties.push('invalid value for "transaction", transaction cannot be nil.') + if @is_external.nil? + invalid_properties.push('invalid value for "is_external", is_external cannot be nil.') end invalid_properties @@ -223,13 +229,11 @@ def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @smart_contract_id.nil? return false if @network_id.nil? - return false if @wallet_id.nil? return false if @contract_address.nil? - return false if @deployer_address.nil? + return false if @contract_name.nil? return false if @type.nil? - return false if @options.nil? return false if @abi.nil? - return false if @transaction.nil? + return false if @is_external.nil? true end @@ -242,11 +246,13 @@ def ==(o) network_id == o.network_id && wallet_id == o.wallet_id && contract_address == o.contract_address && + contract_name == o.contract_name && deployer_address == o.deployer_address && type == o.type && options == o.options && abi == o.abi && - transaction == o.transaction + transaction == o.transaction && + is_external == o.is_external end # @see the `==` method @@ -258,7 +264,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [smart_contract_id, network_id, wallet_id, contract_address, deployer_address, type, options, abi, transaction].hash + [smart_contract_id, network_id, wallet_id, contract_address, contract_name, deployer_address, type, options, abi, transaction, is_external].hash end # Builds the object from hash diff --git a/lib/coinbase/client/models/smart_contract_activity_event.rb b/lib/coinbase/client/models/smart_contract_activity_event.rb new file mode 100644 index 00000000..1dba2a07 --- /dev/null +++ b/lib/coinbase/client/models/smart_contract_activity_event.rb @@ -0,0 +1,386 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha + +Generated by: https://openapi-generator.tech +Generator version: 7.9.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # Represents an event triggered by a smart contract activity on the blockchain. Contains information about the function, transaction, block, and involved addresses. + class SmartContractActivityEvent + # Unique identifier for the webhook that triggered this event. + attr_accessor :webhook_id + + # Type of event, in this case, an ERC-721 token transfer. + attr_accessor :event_type + + # Blockchain network where the event occurred. + attr_accessor :network + + # Name of the project this smart contract belongs to. + attr_accessor :project_name + + # Name of the contract. + attr_accessor :contract_name + + # Name of the function. + attr_accessor :func + + # Signature of the function. + attr_accessor :sig + + # First 4 bytes of the Transaction, a unique ID. + attr_accessor :four_bytes + + # Address of the smart contract. + attr_accessor :contract_address + + # Hash of the block containing the transaction. + attr_accessor :block_hash + + # Number of the block containing the transaction. + attr_accessor :block_number + + # Timestamp when the block was mined. + attr_accessor :block_time + + # Hash of the transaction that triggered the event. + attr_accessor :transaction_hash + + # Position of the transaction within the block. + attr_accessor :transaction_index + + # Position of the event log within the transaction. + attr_accessor :log_index + + # Address of the initiator in the transfer. + attr_accessor :from + + # Address of the recipient in the transfer. + attr_accessor :to + + # Amount of tokens transferred, typically in the smallest unit (e.g., wei for Ethereum). + attr_accessor :value + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'webhook_id' => :'webhookId', + :'event_type' => :'eventType', + :'network' => :'network', + :'project_name' => :'projectName', + :'contract_name' => :'contractName', + :'func' => :'func', + :'sig' => :'sig', + :'four_bytes' => :'fourBytes', + :'contract_address' => :'contractAddress', + :'block_hash' => :'blockHash', + :'block_number' => :'blockNumber', + :'block_time' => :'blockTime', + :'transaction_hash' => :'transactionHash', + :'transaction_index' => :'transactionIndex', + :'log_index' => :'logIndex', + :'from' => :'from', + :'to' => :'to', + :'value' => :'value' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'webhook_id' => :'String', + :'event_type' => :'String', + :'network' => :'String', + :'project_name' => :'String', + :'contract_name' => :'String', + :'func' => :'String', + :'sig' => :'String', + :'four_bytes' => :'String', + :'contract_address' => :'String', + :'block_hash' => :'String', + :'block_number' => :'Integer', + :'block_time' => :'Time', + :'transaction_hash' => :'String', + :'transaction_index' => :'Integer', + :'log_index' => :'Integer', + :'from' => :'String', + :'to' => :'String', + :'value' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::SmartContractActivityEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::SmartContractActivityEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'webhook_id') + self.webhook_id = attributes[:'webhook_id'] + end + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'network') + self.network = attributes[:'network'] + end + + if attributes.key?(:'project_name') + self.project_name = attributes[:'project_name'] + end + + if attributes.key?(:'contract_name') + self.contract_name = attributes[:'contract_name'] + end + + if attributes.key?(:'func') + self.func = attributes[:'func'] + end + + if attributes.key?(:'sig') + self.sig = attributes[:'sig'] + end + + if attributes.key?(:'four_bytes') + self.four_bytes = attributes[:'four_bytes'] + end + + if attributes.key?(:'contract_address') + self.contract_address = attributes[:'contract_address'] + end + + if attributes.key?(:'block_hash') + self.block_hash = attributes[:'block_hash'] + end + + if attributes.key?(:'block_number') + self.block_number = attributes[:'block_number'] + end + + if attributes.key?(:'block_time') + self.block_time = attributes[:'block_time'] + end + + if attributes.key?(:'transaction_hash') + self.transaction_hash = attributes[:'transaction_hash'] + end + + if attributes.key?(:'transaction_index') + self.transaction_index = attributes[:'transaction_index'] + end + + if attributes.key?(:'log_index') + self.log_index = attributes[:'log_index'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + webhook_id == o.webhook_id && + event_type == o.event_type && + network == o.network && + project_name == o.project_name && + contract_name == o.contract_name && + func == o.func && + sig == o.sig && + four_bytes == o.four_bytes && + contract_address == o.contract_address && + block_hash == o.block_hash && + block_number == o.block_number && + block_time == o.block_time && + transaction_hash == o.transaction_hash && + transaction_index == o.transaction_index && + log_index == o.log_index && + from == o.from && + to == o.to && + value == o.value + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [webhook_id, event_type, network, project_name, contract_name, func, sig, four_bytes, contract_address, block_hash, block_number, block_time, transaction_hash, transaction_index, log_index, from, to, value].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/smart_contract_type.rb b/lib/coinbase/client/models/smart_contract_type.rb index 3d0f0bfd..f41bbd72 100644 --- a/lib/coinbase/client/models/smart_contract_type.rb +++ b/lib/coinbase/client/models/smart_contract_type.rb @@ -18,10 +18,11 @@ class SmartContractType ERC20 = "erc20".freeze ERC721 = "erc721".freeze ERC1155 = "erc1155".freeze + CUSTOM = "custom".freeze UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze def self.all_vars - @all_vars ||= [ERC20, ERC721, ERC1155, UNKNOWN_DEFAULT_OPEN_API].freeze + @all_vars ||= [ERC20, ERC721, ERC1155, CUSTOM, UNKNOWN_DEFAULT_OPEN_API].freeze end # Builds the enum from string diff --git a/lib/coinbase/client/models/webhook_event_type.rb b/lib/coinbase/client/models/webhook_event_type.rb index df57b98c..9ab7ffad 100644 --- a/lib/coinbase/client/models/webhook_event_type.rb +++ b/lib/coinbase/client/models/webhook_event_type.rb @@ -19,10 +19,11 @@ class WebhookEventType ERC20_TRANSFER = "erc20_transfer".freeze ERC721_TRANSFER = "erc721_transfer".freeze WALLET_ACTIVITY = "wallet_activity".freeze + SMART_CONTRACT_EVENT_ACTIVITY = "smart_contract_event_activity".freeze UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze def self.all_vars - @all_vars ||= [UNSPECIFIED, ERC20_TRANSFER, ERC721_TRANSFER, WALLET_ACTIVITY, UNKNOWN_DEFAULT_OPEN_API].freeze + @all_vars ||= [UNSPECIFIED, ERC20_TRANSFER, ERC721_TRANSFER, WALLET_ACTIVITY, SMART_CONTRACT_EVENT_ACTIVITY, UNKNOWN_DEFAULT_OPEN_API].freeze end # Builds the enum from string diff --git a/lib/coinbase/client/models/webhook_event_type_filter.rb b/lib/coinbase/client/models/webhook_event_type_filter.rb index 7e6dcbd2..c8dd017b 100644 --- a/lib/coinbase/client/models/webhook_event_type_filter.rb +++ b/lib/coinbase/client/models/webhook_event_type_filter.rb @@ -20,6 +20,7 @@ class << self # List of class defined in oneOf (OpenAPI v3) def openapi_one_of [ + :'WebhookSmartContractEventFilter', :'WebhookWalletActivityFilter' ] end diff --git a/lib/coinbase/client/models/address_risk.rb b/lib/coinbase/client/models/webhook_smart_contract_event_filter.rb similarity index 84% rename from lib/coinbase/client/models/address_risk.rb rename to lib/coinbase/client/models/webhook_smart_contract_event_filter.rb index 570f4385..b0e54e18 100644 --- a/lib/coinbase/client/models/address_risk.rb +++ b/lib/coinbase/client/models/webhook_smart_contract_event_filter.rb @@ -14,15 +14,15 @@ require 'time' module Coinbase::Client - # The risk score of a blockchain address. - class AddressRisk - # The lower the score is, the higher the risk is. The score lies between -100 to 0. - attr_accessor :risk_score + # Filter for smart contract events. This filter allows the client to specify smart contract addresses to monitor for activities such as contract function calls. + class WebhookSmartContractEventFilter + # A list of smart contract addresses to filter on. + attr_accessor :contract_addresses # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'risk_score' => :'risk_score' + :'contract_addresses' => :'contract_addresses' } end @@ -34,7 +34,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'risk_score' => :'Integer' + :'contract_addresses' => :'Array' } end @@ -48,21 +48,23 @@ def self.openapi_nullable # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::AddressRisk` initialize method" + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::WebhookSmartContractEventFilter` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::AddressRisk`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + 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 end h[k.to_sym] = v } - if attributes.key?(:'risk_score') - self.risk_score = attributes[:'risk_score'] + if attributes.key?(:'contract_addresses') + if (value = attributes[:'contract_addresses']).is_a?(Array) + self.contract_addresses = value + end else - self.risk_score = nil + self.contract_addresses = nil end end @@ -71,8 +73,8 @@ def initialize(attributes = {}) def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new - if @risk_score.nil? - invalid_properties.push('invalid value for "risk_score", risk_score cannot be nil.') + if @contract_addresses.nil? + invalid_properties.push('invalid value for "contract_addresses", contract_addresses cannot be nil.') end invalid_properties @@ -82,7 +84,7 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' - return false if @risk_score.nil? + return false if @contract_addresses.nil? true end @@ -91,7 +93,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && - risk_score == o.risk_score + contract_addresses == o.contract_addresses end # @see the `==` method @@ -103,7 +105,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [risk_score].hash + [contract_addresses].hash end # Builds the object from hash diff --git a/lib/coinbase/client/models/webhook_wallet_activity_filter.rb b/lib/coinbase/client/models/webhook_wallet_activity_filter.rb index 1f70afa4..7d200d5f 100644 --- a/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +++ b/lib/coinbase/client/models/webhook_wallet_activity_filter.rb @@ -72,6 +72,8 @@ def initialize(attributes = {}) if attributes.key?(:'wallet_id') self.wallet_id = attributes[:'wallet_id'] + else + self.wallet_id = nil end end @@ -80,6 +82,10 @@ def initialize(attributes = {}) def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new + if @wallet_id.nil? + invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.') + end + invalid_properties end @@ -87,6 +93,7 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @wallet_id.nil? true end diff --git a/spec/factories/address_reputation.rb b/spec/factories/address_reputation.rb new file mode 100644 index 00000000..449ed48e --- /dev/null +++ b/spec/factories/address_reputation.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :address_reputation_model, class: Coinbase::Client::AddressReputation do + score { 50 } + metadata do + { + total_transactions: 1, + unique_days_active: 1, + longest_active_streak: 1, + current_active_streak: 2, + activity_period_days: 3, + bridge_transactions_performed: 4, + lend_borrow_stake_transactions: 5, + ens_contract_interactions: 6, + smart_contract_deployments: 7, + token_swaps_performed: 8 + } + end + + initialize_with { new(attributes) } + end + + factory :address_reputation, class: Coinbase::AddressReputation do + transient do + score { nil } + metadata { nil } + + model do + build( + :address_reputation_model, + { score: score, metadata: metadata }.compact + ) + end + end + + initialize_with { Coinbase::AddressReputation.new(model) } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5bb1b8a3..ab95d768 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,7 @@ require_relative 'support/shared_examples/address_staking' require_relative 'support/shared_examples/address_transactions' require_relative 'support/shared_examples/pagination' +require_relative 'support/shared_examples/address_reputation' # Networks and Asset symbols used in our test factories. NETWORK_TRAITS = %i[base_mainnet base_sepolia ethereum_holesky ethereum_mainnet].freeze diff --git a/spec/support/shared_examples/address_reputation.rb b/spec/support/shared_examples/address_reputation.rb new file mode 100644 index 00000000..ce62c7a2 --- /dev/null +++ b/spec/support/shared_examples/address_reputation.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +shared_examples 'an address that supports reputation' do + let(:score) { 50 } + let(:metadata) { { total_transactions: 10, unique_days_active: 42 } } + let(:address_reputation) { build(:address_reputation, score: score, metadata: metadata) } + + before do + allow(Coinbase::AddressReputation).to receive(:fetch).and_return(address_reputation) + end + + it 'fetches the address reputation from the API' do + expect(address.reputation).to be_a(Coinbase::AddressReputation) + end + + it 'returns the reputation score' do + expect(address_reputation.score).to eq(score) + end + + it 'returns metadata as a Metadata object' do + expect(address_reputation.metadata).to be_a(Coinbase::AddressReputation::Metadata) + end + + it 'has correct metadata values for total transactions' do + expect(address_reputation.metadata.total_transactions).to eq(metadata[:total_transactions]) + end + + it 'has correct metadata values for unique days active' do + expect(address_reputation.metadata.unique_days_active).to eq(metadata[:unique_days_active]) + end +end diff --git a/spec/unit/coinbase/address/external_address_spec.rb b/spec/unit/coinbase/address/external_address_spec.rb index 24d003cc..5b8af3b8 100644 --- a/spec/unit/coinbase/address/external_address_spec.rb +++ b/spec/unit/coinbase/address/external_address_spec.rb @@ -34,4 +34,5 @@ it_behaves_like 'an address that supports requesting faucet funds' it_behaves_like 'an address that supports transaction queries' it_behaves_like 'an address that supports staking' + it_behaves_like 'an address that supports reputation' end diff --git a/spec/unit/coinbase/address/wallet_address_spec.rb b/spec/unit/coinbase/address/wallet_address_spec.rb index 382591e8..5bc9d461 100644 --- a/spec/unit/coinbase/address/wallet_address_spec.rb +++ b/spec/unit/coinbase/address/wallet_address_spec.rb @@ -101,6 +101,7 @@ it_behaves_like 'an address that supports balance queries' it_behaves_like 'an address that supports requesting faucet funds' it_behaves_like 'an address that supports staking' + it_behaves_like 'an address that supports reputation' describe '#invoke_contract' do subject(:contract_invocation) do diff --git a/spec/unit/coinbase/address_reputation_spec.rb b/spec/unit/coinbase/address_reputation_spec.rb new file mode 100644 index 00000000..133e81a8 --- /dev/null +++ b/spec/unit/coinbase/address_reputation_spec.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true + +describe Coinbase::AddressReputation do + subject(:address_reputation) { described_class.new(model) } + + let(:address_id) { '0x123456789abcdef' } + let(:network) { 'ethereum-mainnet' } + let(:score) { 50 } + let(:model) { build(:address_reputation_model, score: score) } + + describe '.fetch' do + subject(:address_reputation) { described_class.fetch(address_id: address_id, network: network) } + + let(:api_instance) { instance_double(Coinbase::Client::ReputationApi) } + + before do + allow(Coinbase::Client::ReputationApi).to receive(:new).and_return(api_instance) + allow(api_instance).to receive(:get_address_reputation).and_return(model) + + address_reputation + end + + it 'fetches address reputation for the given network and address' do + expect(api_instance).to have_received(:get_address_reputation).with(network, address_id) + end + + it 'returns an AddressReputation object' do + expect(address_reputation).to be_a(described_class) + end + + it 'returns an object initialized with the correct model' do + expect(address_reputation.instance_variable_get(:@model)).to eq(model) + end + + it 'raises an error if the API returns an invalid model' do + allow(api_instance).to receive(:get_address_reputation).and_return(nil) + + expect do + described_class.fetch(address_id: address_id, network: network) + end.to raise_error(ArgumentError, 'must be an AddressReputation object') + end + end + + describe '#score' do + it 'returns the reputation score' do + expect(address_reputation.score).to eq(score) + end + end + + describe '#metadata' do + it 'returns a Metadata object' do + expect(address_reputation.metadata).to be_a(described_class::Metadata) + end + + it 'initalizes the metadata object properly' do + model.metadata.all? do |key, value| + expect(address_reputation.metadata.send(key)).to eq(value) + end + end + end + + describe '#risky?' do + context 'when the score is positive' do + let(:score) { 42 } + + it 'returns false' do + expect(address_reputation).not_to be_risky + end + end + + context 'when the score is negative' do + let(:score) { -10 } + + it 'returns true' do + expect(address_reputation).to be_risky + end + end + end + + describe '#to_s' do + it 'includes the score and the metadata details' do + expect(address_reputation.inspect).to include( + score.to_s, + *address_reputation.metadata.to_h.values.map(&:to_s) + ) + end + end + + describe '#inspect' do + it 'matches the output of #to_s' do + expect(address_reputation.inspect).to eq(address_reputation.to_s) + end + end +end diff --git a/spec/unit/coinbase/address_spec.rb b/spec/unit/coinbase/address_spec.rb index dba93986..b6c432b4 100644 --- a/spec/unit/coinbase/address_spec.rb +++ b/spec/unit/coinbase/address_spec.rb @@ -28,6 +28,21 @@ subject { address.to_s } it { is_expected.to include(network_id.to_s, address_id) } + + context 'when the address reputation is not loaded' do + it { is_expected.not_to include('reputation_score') } + end + + context 'when the address reputation is loaded' do + let(:score) { 37 } + let(:reputation) { build(:address_reputation, score: score) } + + before do + address.instance_variable_set(:@reputation, reputation) + end + + it { is_expected.to include('reputation_score', score.to_s) } + end end describe '#inspect' do @@ -45,4 +60,5 @@ it_behaves_like 'an address that supports balance queries' it_behaves_like 'an address that supports requesting faucet funds' it_behaves_like 'an address that supports transaction queries' + it_behaves_like 'an address that supports reputation' end From 99d619728efe52754db780e3f72c69126595399b Mon Sep 17 00:00:00 2001 From: Ryan Gilbert Date: Thu, 19 Dec 2024 09:57:53 -0500 Subject: [PATCH 2/4] chore(PSDK-640): add network_id to WalletData (#223) --- CHANGELOG.md | 1 + lib/coinbase/wallet.rb | 5 +++-- lib/coinbase/wallet/data.rb | 10 ++++++---- spec/unit/coinbase/wallet_spec.rb | 16 ++++++++++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9643f20..7ef24570 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased * Add support for fetching address reputation. +* Add `network_id` to `WalletData` so that it is saved with the seed data and surfaced via the export function ## [0.12.0] - Skipped diff --git a/lib/coinbase/wallet.rb b/lib/coinbase/wallet.rb index 10b51a4a..0f534745 100644 --- a/lib/coinbase/wallet.rb +++ b/lib/coinbase/wallet.rb @@ -406,7 +406,7 @@ def export raise 'Cannot export Wallet without loaded seed' if @master.nil? - Data.new(wallet_id: id, seed: @master.seed_hex) + Data.new(wallet_id: id, seed: @master.seed_hex, network_id: network.id) end # Returns whether the Wallet has a seed with which to derive keys and sign transactions. @@ -447,7 +447,8 @@ def save_seed!(file_path, encrypt: false) seed: seed_to_store, encrypted: encrypt, auth_tag: auth_tag, - iv: iv + iv: iv, + network_id: network.id } File.write(file_path, JSON.pretty_generate(existing_seeds_in_store)) diff --git a/lib/coinbase/wallet/data.rb b/lib/coinbase/wallet/data.rb index 171aaf30..c89a0998 100644 --- a/lib/coinbase/wallet/data.rb +++ b/lib/coinbase/wallet/data.rb @@ -4,27 +4,29 @@ module Coinbase class Wallet # The data required to recreate a Wallet. class Data - attr_reader :wallet_id, :seed + attr_reader :wallet_id, :seed, :network_id # Returns a new Data object. # @param wallet_id [String] The ID of the Wallet # @param seed [String] The seed of the Wallet - def initialize(wallet_id:, seed:) + # @param network_id [String, nil] The network ID of the Wallet (optional) + def initialize(wallet_id:, seed:, network_id: nil) @wallet_id = wallet_id @seed = seed + @network_id = network_id end # Converts the Data object to a Hash. # @return [Hash] The Hash representation of the Data object def to_hash - { wallet_id: wallet_id, seed: seed } + { wallet_id: wallet_id, seed: seed, network_id: network_id } end # Creates a Data object from the given Hash. # @param data [Hash] The Hash to create the Data object from # @return [Data] The new Data object def self.from_hash(data) - Data.new(wallet_id: data['wallet_id'], seed: data['seed']) + Data.new(wallet_id: data['wallet_id'], seed: data['seed'], network_id: data['network_id']) end end end diff --git a/spec/unit/coinbase/wallet_spec.rb b/spec/unit/coinbase/wallet_spec.rb index 6a663bb4..b27d1634 100644 --- a/spec/unit/coinbase/wallet_spec.rb +++ b/spec/unit/coinbase/wallet_spec.rb @@ -1350,7 +1350,13 @@ def match_create_address_request(req, expected_public_key, expected_address_inde it 'saves the wallet data to the seed file' do expect(saved_seed_data[wallet.id]) - .to eq({ 'seed' => seed, 'encrypted' => false, 'iv' => '', 'auth_tag' => '' }) + .to eq({ + 'seed' => seed, + 'encrypted' => false, + 'iv' => '', + 'auth_tag' => '', + 'network_id' => network_id.to_s + }) end end @@ -1387,7 +1393,13 @@ def match_create_address_request(req, expected_public_key, expected_address_inde it 'saves the wallet data to the new file' do expect(saved_seed_data[wallet.id]) - .to eq({ 'seed' => seed, 'encrypted' => false, 'iv' => '', 'auth_tag' => '' }) + .to eq({ + 'seed' => seed, + 'encrypted' => false, + 'iv' => '', + 'auth_tag' => '', + 'network_id' => network_id.to_s + }) end end From 8bb7c70fff4c3683f809b27dd5f05362574c4992 Mon Sep 17 00:00:00 2001 From: Alexander Stone Date: Thu, 19 Dec 2024 10:48:54 -0800 Subject: [PATCH 3/4] feat: Support registering and updating external smart contracts (#220) ### What changed? Why? This starts to add support for registering external smart contracts with CDP. This will enable developers to use these register smart contracts to invoke, read, and create webhooks associated with the contract! ### Testing ```ruby # Deploy a token and get an ERC20 ABI ref smart_contract = wallet.deploy_token(name: "Test Coin", symbol: "TEST", total_supply: 1000) smart_contract.wait! asset = Coinbase::Asset.fetch(:base_sepolia, :usdc) # Register an external contract w/ a known ABI external_contract = Coinbase::SmartContract.register( network: Coinbase::Network::BASE_SEPOLIA, contract_address: asset.address_id, name: "USDC YO", abi: smart_contract.abi ) external_contract.update(name: "Base Sepolia USDC Contract") ``` #### Qualified Impact --- CHANGELOG.md | 2 + lib/coinbase/client.rb | 6 +- lib/coinbase/client/api/addresses_api.rb | 20 +- lib/coinbase/client/api/assets_api.rb | 4 +- .../client/api/balance_history_api.rb | 4 +- .../client/api/contract_events_api.rb | 4 +- .../client/api/contract_invocations_api.rb | 10 +- .../client/api/external_addresses_api.rb | 251 +++++++- lib/coinbase/client/api/fund_api.rb | 10 +- .../client/api/mpc_wallet_stake_api.rb | 8 +- lib/coinbase/client/api/networks_api.rb | 4 +- .../client/api/onchain_identity_api.rb | 4 +- lib/coinbase/client/api/reputation_api.rb | 4 +- lib/coinbase/client/api/server_signers_api.rb | 14 +- .../client/api/smart_contracts_api.rb | 90 ++- lib/coinbase/client/api/stake_api.rb | 16 +- lib/coinbase/client/api/trades_api.rb | 10 +- .../client/api/transaction_history_api.rb | 4 +- lib/coinbase/client/api/transfers_api.rb | 28 +- lib/coinbase/client/api/users_api.rb | 2 +- lib/coinbase/client/api/wallets_api.rb | 12 +- lib/coinbase/client/api/webhooks_api.rb | 12 +- lib/coinbase/client/api_client.rb | 2 +- lib/coinbase/client/api_error.rb | 2 +- lib/coinbase/client/configuration.rb | 16 +- lib/coinbase/client/models/address.rb | 2 +- .../client/models/address_balance_list.rb | 2 +- .../models/address_historical_balance_list.rb | 2 +- lib/coinbase/client/models/address_list.rb | 2 +- .../client/models/address_reputation.rb | 2 +- .../models/address_reputation_metadata.rb | 2 +- .../client/models/address_transaction_list.rb | 2 +- lib/coinbase/client/models/asset.rb | 2 +- lib/coinbase/client/models/balance.rb | 2 +- .../broadcast_contract_invocation_request.rb | 2 +- ...=> broadcast_external_transfer_request.rb} | 8 +- .../broadcast_staking_operation_request.rb | 2 +- .../client/models/broadcast_trade_request.rb | 2 +- .../models/build_staking_operation_request.rb | 2 +- lib/coinbase/client/models/contract_event.rb | 2 +- .../client/models/contract_event_list.rb | 2 +- .../client/models/contract_invocation.rb | 2 +- .../client/models/contract_invocation_list.rb | 2 +- .../client/models/create_address_request.rb | 2 +- .../create_contract_invocation_request.rb | 2 +- .../create_external_transfer_request.rb | 273 ++++++++ .../models/create_fund_operation_request.rb | 4 +- .../models/create_fund_quote_request.rb | 4 +- .../create_payload_signature_request.rb | 2 +- .../models/create_server_signer_request.rb | 2 +- .../models/create_smart_contract_request.rb | 2 +- .../create_staking_operation_request.rb | 2 +- .../client/models/create_trade_request.rb | 2 +- .../client/models/create_transfer_request.rb | 4 +- .../client/models/create_wallet_request.rb | 2 +- .../models/create_wallet_request_wallet.rb | 2 +- .../models/create_wallet_webhook_request.rb | 2 +- .../client/models/create_webhook_request.rb | 2 +- lib/coinbase/client/models/crypto_amount.rb | 2 +- .../models/deploy_smart_contract_request.rb | 2 +- .../client/models/erc20_transfer_event.rb | 2 +- .../client/models/erc721_transfer_event.rb | 2 +- lib/coinbase/client/models/error.rb | 2 +- .../client/models/ethereum_token_transfer.rb | 2 +- .../client/models/ethereum_transaction.rb | 2 +- .../models/ethereum_transaction_access.rb | 2 +- .../ethereum_transaction_access_list.rb | 2 +- .../ethereum_transaction_flattened_trace.rb | 2 +- .../models/ethereum_validator_metadata.rb | 2 +- .../client/models/faucet_transaction.rb | 2 +- lib/coinbase/client/models/feature_set.rb | 2 +- ...historical_staking_balances200_response.rb | 2 +- .../fetch_staking_rewards200_response.rb | 2 +- .../models/fetch_staking_rewards_request.rb | 2 +- lib/coinbase/client/models/fiat_amount.rb | 2 +- lib/coinbase/client/models/fund_operation.rb | 2 +- .../client/models/fund_operation_fees.rb | 2 +- .../client/models/fund_operation_list.rb | 2 +- lib/coinbase/client/models/fund_quote.rb | 2 +- .../models/get_staking_context_request.rb | 2 +- .../client/models/historical_balance.rb | 2 +- .../models/multi_token_contract_options.rb | 2 +- lib/coinbase/client/models/network.rb | 2 +- .../client/models/network_identifier.rb | 2 +- .../client/models/nft_contract_options.rb | 2 +- lib/coinbase/client/models/onchain_name.rb | 2 +- .../client/models/onchain_name_list.rb | 2 +- .../client/models/payload_signature.rb | 2 +- .../client/models/payload_signature_list.rb | 2 +- .../client/models/read_contract_request.rb | 2 +- .../models/register_smart_contract_request.rb | 24 +- .../client/models/seed_creation_event.rb | 2 +- .../models/seed_creation_event_result.rb | 2 +- lib/coinbase/client/models/server_signer.rb | 2 +- .../client/models/server_signer_event.rb | 2 +- .../models/server_signer_event_event.rb | 2 +- .../client/models/server_signer_event_list.rb | 2 +- .../client/models/server_signer_list.rb | 2 +- .../client/models/signature_creation_event.rb | 2 +- .../models/signature_creation_event_result.rb | 2 +- .../signed_voluntary_exit_message_metadata.rb | 2 +- lib/coinbase/client/models/smart_contract.rb | 2 +- .../models/smart_contract_activity_event.rb | 2 +- .../client/models/smart_contract_list.rb | 2 +- .../client/models/smart_contract_options.rb | 2 +- .../client/models/smart_contract_type.rb | 2 +- lib/coinbase/client/models/solidity_value.rb | 2 +- lib/coinbase/client/models/sponsored_send.rb | 2 +- lib/coinbase/client/models/staking_balance.rb | 2 +- lib/coinbase/client/models/staking_context.rb | 2 +- .../client/models/staking_context_context.rb | 2 +- .../client/models/staking_operation.rb | 2 +- .../models/staking_operation_metadata.rb | 2 +- lib/coinbase/client/models/staking_reward.rb | 2 +- .../client/models/staking_reward_format.rb | 2 +- .../client/models/staking_reward_usd_value.rb | 2 +- .../client/models/token_contract_options.rb | 2 +- .../client/models/token_transfer_type.rb | 2 +- lib/coinbase/client/models/trade.rb | 2 +- lib/coinbase/client/models/trade_list.rb | 2 +- lib/coinbase/client/models/transaction.rb | 2 +- .../client/models/transaction_content.rb | 2 +- .../client/models/transaction_type.rb | 2 +- lib/coinbase/client/models/transfer.rb | 39 +- lib/coinbase/client/models/transfer_list.rb | 2 +- .../models/update_smart_contract_request.rb | 245 ++++++++ .../client/models/update_webhook_request.rb | 2 +- lib/coinbase/client/models/user.rb | 2 +- lib/coinbase/client/models/validator.rb | 2 +- .../client/models/validator_details.rb | 2 +- lib/coinbase/client/models/validator_list.rb | 2 +- .../client/models/validator_status.rb | 2 +- lib/coinbase/client/models/wallet.rb | 2 +- lib/coinbase/client/models/wallet_list.rb | 2 +- lib/coinbase/client/models/webhook.rb | 2 +- .../client/models/webhook_event_filter.rb | 2 +- .../client/models/webhook_event_type.rb | 2 +- .../models/webhook_event_type_filter.rb | 2 +- lib/coinbase/client/models/webhook_list.rb | 2 +- .../webhook_smart_contract_event_filter.rb | 2 +- .../models/webhook_wallet_activity_filter.rb | 2 +- lib/coinbase/client/version.rb | 2 +- lib/coinbase/errors.rb | 8 + lib/coinbase/smart_contract.rb | 583 ++++++++++-------- spec/factories/smart_contract.rb | 23 +- spec/unit/coinbase/smart_contract_spec.rb | 397 +++++++++++- 146 files changed, 1844 insertions(+), 525 deletions(-) rename lib/coinbase/client/models/{broadcast_transfer_request.rb => broadcast_external_transfer_request.rb} (95%) create mode 100644 lib/coinbase/client/models/create_external_transfer_request.rb create mode 100644 lib/coinbase/client/models/update_smart_contract_request.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ef24570..ae685bbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased * Add support for fetching address reputation. * Add `network_id` to `WalletData` so that it is saved with the seed data and surfaced via the export function +* Add support for registering, updating, and listing smart contracts that are + deployed external to CDP. ## [0.12.0] - Skipped diff --git a/lib/coinbase/client.rb b/lib/coinbase/client.rb index 04f31ee7..0e9811b5 100644 --- a/lib/coinbase/client.rb +++ b/lib/coinbase/client.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -27,9 +27,9 @@ Coinbase::Client.autoload :Asset, 'coinbase/client/models/asset' Coinbase::Client.autoload :Balance, 'coinbase/client/models/balance' Coinbase::Client.autoload :BroadcastContractInvocationRequest, 'coinbase/client/models/broadcast_contract_invocation_request' +Coinbase::Client.autoload :BroadcastExternalTransferRequest, 'coinbase/client/models/broadcast_external_transfer_request' Coinbase::Client.autoload :BroadcastStakingOperationRequest, 'coinbase/client/models/broadcast_staking_operation_request' Coinbase::Client.autoload :BroadcastTradeRequest, 'coinbase/client/models/broadcast_trade_request' -Coinbase::Client.autoload :BroadcastTransferRequest, 'coinbase/client/models/broadcast_transfer_request' Coinbase::Client.autoload :BuildStakingOperationRequest, 'coinbase/client/models/build_staking_operation_request' Coinbase::Client.autoload :ContractEvent, 'coinbase/client/models/contract_event' Coinbase::Client.autoload :ContractEventList, 'coinbase/client/models/contract_event_list' @@ -37,6 +37,7 @@ Coinbase::Client.autoload :ContractInvocationList, 'coinbase/client/models/contract_invocation_list' Coinbase::Client.autoload :CreateAddressRequest, 'coinbase/client/models/create_address_request' Coinbase::Client.autoload :CreateContractInvocationRequest, 'coinbase/client/models/create_contract_invocation_request' +Coinbase::Client.autoload :CreateExternalTransferRequest, 'coinbase/client/models/create_external_transfer_request' Coinbase::Client.autoload :CreateFundOperationRequest, 'coinbase/client/models/create_fund_operation_request' Coinbase::Client.autoload :CreateFundQuoteRequest, 'coinbase/client/models/create_fund_quote_request' Coinbase::Client.autoload :CreatePayloadSignatureRequest, 'coinbase/client/models/create_payload_signature_request' @@ -116,6 +117,7 @@ Coinbase::Client.autoload :TransactionType, 'coinbase/client/models/transaction_type' Coinbase::Client.autoload :Transfer, 'coinbase/client/models/transfer' Coinbase::Client.autoload :TransferList, 'coinbase/client/models/transfer_list' +Coinbase::Client.autoload :UpdateSmartContractRequest, 'coinbase/client/models/update_smart_contract_request' Coinbase::Client.autoload :UpdateWebhookRequest, 'coinbase/client/models/update_webhook_request' Coinbase::Client.autoload :User, 'coinbase/client/models/user' Coinbase::Client.autoload :Validator, 'coinbase/client/models/validator' diff --git a/lib/coinbase/client/api/addresses_api.rb b/lib/coinbase/client/api/addresses_api.rb index 70f55c91..5e98bf3c 100644 --- a/lib/coinbase/client/api/addresses_api.rb +++ b/lib/coinbase/client/api/addresses_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -70,7 +70,7 @@ def create_address_with_http_info(wallet_id, opts = {}) return_type = opts[:debug_return_type] || 'Address' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"AddressesApi.create_address", @@ -146,7 +146,7 @@ def create_payload_signature_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'PayloadSignature' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"AddressesApi.create_payload_signature", @@ -215,7 +215,7 @@ def get_address_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'Address' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"AddressesApi.get_address", @@ -290,7 +290,7 @@ def get_address_balance_with_http_info(wallet_id, address_id, asset_id, opts = { return_type = opts[:debug_return_type] || 'Balance' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"AddressesApi.get_address_balance", @@ -365,7 +365,7 @@ def get_payload_signature_with_http_info(wallet_id, address_id, payload_signatur return_type = opts[:debug_return_type] || 'PayloadSignature' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"AddressesApi.get_payload_signature", @@ -441,7 +441,7 @@ def list_address_balances_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'AddressBalanceList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"AddressesApi.list_address_balances", @@ -514,7 +514,7 @@ def list_addresses_with_http_info(wallet_id, opts = {}) return_type = opts[:debug_return_type] || 'AddressList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"AddressesApi.list_addresses", @@ -593,7 +593,7 @@ def list_payload_signatures_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'PayloadSignatureList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"AddressesApi.list_payload_signatures", @@ -665,7 +665,7 @@ def request_faucet_funds_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'FaucetTransaction' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"AddressesApi.request_faucet_funds", diff --git a/lib/coinbase/client/api/assets_api.rb b/lib/coinbase/client/api/assets_api.rb index ad9e9593..f6c86cec 100644 --- a/lib/coinbase/client/api/assets_api.rb +++ b/lib/coinbase/client/api/assets_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -69,7 +69,7 @@ def get_asset_with_http_info(network_id, asset_id, opts = {}) return_type = opts[:debug_return_type] || 'Asset' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"AssetsApi.get_asset", diff --git a/lib/coinbase/client/api/balance_history_api.rb b/lib/coinbase/client/api/balance_history_api.rb index d66ab8fd..b184c488 100644 --- a/lib/coinbase/client/api/balance_history_api.rb +++ b/lib/coinbase/client/api/balance_history_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -85,7 +85,7 @@ def list_address_historical_balance_with_http_info(network_id, address_id, asset return_type = opts[:debug_return_type] || 'AddressHistoricalBalanceList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"BalanceHistoryApi.list_address_historical_balance", diff --git a/lib/coinbase/client/api/contract_events_api.rb b/lib/coinbase/client/api/contract_events_api.rb index b155304b..1e4a277f 100644 --- a/lib/coinbase/client/api/contract_events_api.rb +++ b/lib/coinbase/client/api/contract_events_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -107,7 +107,7 @@ def list_contract_events_with_http_info(network_id, protocol_name, contract_addr return_type = opts[:debug_return_type] || 'ContractEventList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ContractEventsApi.list_contract_events", diff --git a/lib/coinbase/client/api/contract_invocations_api.rb b/lib/coinbase/client/api/contract_invocations_api.rb index 224bb217..704f3724 100644 --- a/lib/coinbase/client/api/contract_invocations_api.rb +++ b/lib/coinbase/client/api/contract_invocations_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -86,7 +86,7 @@ def broadcast_contract_invocation_with_http_info(wallet_id, address_id, contract return_type = opts[:debug_return_type] || 'ContractInvocation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"ContractInvocationsApi.broadcast_contract_invocation", @@ -166,7 +166,7 @@ def create_contract_invocation_with_http_info(wallet_id, address_id, create_cont return_type = opts[:debug_return_type] || 'ContractInvocation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"ContractInvocationsApi.create_contract_invocation", @@ -241,7 +241,7 @@ def get_contract_invocation_with_http_info(wallet_id, address_id, contract_invoc return_type = opts[:debug_return_type] || 'ContractInvocation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ContractInvocationsApi.get_contract_invocation", @@ -320,7 +320,7 @@ def list_contract_invocations_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'ContractInvocationList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ContractInvocationsApi.list_contract_invocations", diff --git a/lib/coinbase/client/api/external_addresses_api.rb b/lib/coinbase/client/api/external_addresses_api.rb index d6c0f7ec..17aa6223 100644 --- a/lib/coinbase/client/api/external_addresses_api.rb +++ b/lib/coinbase/client/api/external_addresses_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -19,6 +19,172 @@ class ExternalAddressesApi def initialize(api_client = ApiClient.default) @api_client = api_client end + # Broadcast an external address' transfer + # Broadcast an external address's transfer with a signed payload + # @param network_id [String] The ID of the network the address belongs to + # @param address_id [String] The ID of the address the transfer belongs to + # @param transfer_id [String] The ID of the transfer to broadcast + # @param broadcast_external_transfer_request [BroadcastExternalTransferRequest] + # @param [Hash] opts the optional parameters + # @return [Transfer] + def broadcast_external_transfer(network_id, address_id, transfer_id, broadcast_external_transfer_request, opts = {}) + data, _status_code, _headers = broadcast_external_transfer_with_http_info(network_id, address_id, transfer_id, broadcast_external_transfer_request, opts) + data + end + + # Broadcast an external address' transfer + # Broadcast an external address's transfer with a signed payload + # @param network_id [String] The ID of the network the address belongs to + # @param address_id [String] The ID of the address the transfer belongs to + # @param transfer_id [String] The ID of the transfer to broadcast + # @param broadcast_external_transfer_request [BroadcastExternalTransferRequest] + # @param [Hash] opts the optional parameters + # @return [Array<(Transfer, Integer, Hash)>] Transfer data, response status code and response headers + def broadcast_external_transfer_with_http_info(network_id, address_id, transfer_id, broadcast_external_transfer_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ExternalAddressesApi.broadcast_external_transfer ...' + end + # verify the required parameter 'network_id' is set + if @api_client.config.client_side_validation && network_id.nil? + fail ArgumentError, "Missing the required parameter 'network_id' when calling ExternalAddressesApi.broadcast_external_transfer" + end + # verify the required parameter 'address_id' is set + if @api_client.config.client_side_validation && address_id.nil? + fail ArgumentError, "Missing the required parameter 'address_id' when calling ExternalAddressesApi.broadcast_external_transfer" + end + # verify the required parameter 'transfer_id' is set + if @api_client.config.client_side_validation && transfer_id.nil? + fail ArgumentError, "Missing the required parameter 'transfer_id' when calling ExternalAddressesApi.broadcast_external_transfer" + end + # verify the required parameter 'broadcast_external_transfer_request' is set + if @api_client.config.client_side_validation && broadcast_external_transfer_request.nil? + fail ArgumentError, "Missing the required parameter 'broadcast_external_transfer_request' when calling ExternalAddressesApi.broadcast_external_transfer" + end + # resource path + local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/transfers/{transfer_id}/broadcast'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'transfer_id' + '}', CGI.escape(transfer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(broadcast_external_transfer_request) + + # return_type + return_type = opts[:debug_return_type] || 'Transfer' + + # auth_names + auth_names = opts[:debug_auth_names] || ['apiKey'] + + new_options = opts.merge( + :operation => :"ExternalAddressesApi.broadcast_external_transfer", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ExternalAddressesApi#broadcast_external_transfer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Create a new transfer + # Create a new transfer between addresses. + # @param network_id [String] The ID of the network the address is on + # @param address_id [String] The ID of the address to transfer from + # @param create_external_transfer_request [CreateExternalTransferRequest] + # @param [Hash] opts the optional parameters + # @return [Transfer] + def create_external_transfer(network_id, address_id, create_external_transfer_request, opts = {}) + data, _status_code, _headers = create_external_transfer_with_http_info(network_id, address_id, create_external_transfer_request, opts) + data + end + + # Create a new transfer + # Create a new transfer between addresses. + # @param network_id [String] The ID of the network the address is on + # @param address_id [String] The ID of the address to transfer from + # @param create_external_transfer_request [CreateExternalTransferRequest] + # @param [Hash] opts the optional parameters + # @return [Array<(Transfer, Integer, Hash)>] Transfer data, response status code and response headers + def create_external_transfer_with_http_info(network_id, address_id, create_external_transfer_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ExternalAddressesApi.create_external_transfer ...' + end + # verify the required parameter 'network_id' is set + if @api_client.config.client_side_validation && network_id.nil? + fail ArgumentError, "Missing the required parameter 'network_id' when calling ExternalAddressesApi.create_external_transfer" + end + # verify the required parameter 'address_id' is set + if @api_client.config.client_side_validation && address_id.nil? + fail ArgumentError, "Missing the required parameter 'address_id' when calling ExternalAddressesApi.create_external_transfer" + end + # verify the required parameter 'create_external_transfer_request' is set + if @api_client.config.client_side_validation && create_external_transfer_request.nil? + fail ArgumentError, "Missing the required parameter 'create_external_transfer_request' when calling ExternalAddressesApi.create_external_transfer" + end + # resource path + local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/transfers'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_external_transfer_request) + + # return_type + return_type = opts[:debug_return_type] || 'Transfer' + + # auth_names + auth_names = opts[:debug_auth_names] || ['apiKey'] + + new_options = opts.merge( + :operation => :"ExternalAddressesApi.create_external_transfer", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ExternalAddressesApi#create_external_transfer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get the balance of an asset in an external address # Get the balance of an asset in an external address # @param network_id [String] The ID of the blockchain network @@ -75,7 +241,7 @@ def get_external_address_balance_with_http_info(network_id, address_id, asset_id return_type = opts[:debug_return_type] || 'Balance' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ExternalAddressesApi.get_external_address_balance", @@ -94,6 +260,81 @@ def get_external_address_balance_with_http_info(network_id, address_id, asset_id return data, status_code, headers end + # Get a external address' transfer + # Get an external address' transfer by ID + # @param network_id [String] The ID of the network the address is on + # @param address_id [String] The ID of the address the transfer belongs to + # @param transfer_id [String] The ID of the transfer to fetch + # @param [Hash] opts the optional parameters + # @return [Transfer] + def get_external_transfer(network_id, address_id, transfer_id, opts = {}) + data, _status_code, _headers = get_external_transfer_with_http_info(network_id, address_id, transfer_id, opts) + data + end + + # Get a external address' transfer + # Get an external address' transfer by ID + # @param network_id [String] The ID of the network the address is on + # @param address_id [String] The ID of the address the transfer belongs to + # @param transfer_id [String] The ID of the transfer to fetch + # @param [Hash] opts the optional parameters + # @return [Array<(Transfer, Integer, Hash)>] Transfer data, response status code and response headers + def get_external_transfer_with_http_info(network_id, address_id, transfer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ExternalAddressesApi.get_external_transfer ...' + end + # verify the required parameter 'network_id' is set + if @api_client.config.client_side_validation && network_id.nil? + fail ArgumentError, "Missing the required parameter 'network_id' when calling ExternalAddressesApi.get_external_transfer" + end + # verify the required parameter 'address_id' is set + if @api_client.config.client_side_validation && address_id.nil? + fail ArgumentError, "Missing the required parameter 'address_id' when calling ExternalAddressesApi.get_external_transfer" + end + # verify the required parameter 'transfer_id' is set + if @api_client.config.client_side_validation && transfer_id.nil? + fail ArgumentError, "Missing the required parameter 'transfer_id' when calling ExternalAddressesApi.get_external_transfer" + end + # resource path + local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/transfers/{transfer_id}'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'transfer_id' + '}', CGI.escape(transfer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Transfer' + + # auth_names + auth_names = opts[:debug_auth_names] || ['apiKey'] + + new_options = opts.merge( + :operation => :"ExternalAddressesApi.get_external_transfer", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ExternalAddressesApi#get_external_transfer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get the status of a faucet transaction # Get the status of a faucet transaction # @param network_id [String] The ID of the blockchain network @@ -150,7 +391,7 @@ def get_faucet_transaction_with_http_info(network_id, address_id, tx_hash, opts return_type = opts[:debug_return_type] || 'FaucetTransaction' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ExternalAddressesApi.get_faucet_transaction", @@ -226,7 +467,7 @@ def list_external_address_balances_with_http_info(network_id, address_id, opts = return_type = opts[:debug_return_type] || 'AddressBalanceList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ExternalAddressesApi.list_external_address_balances", @@ -301,7 +542,7 @@ def request_external_faucet_funds_with_http_info(network_id, address_id, opts = return_type = opts[:debug_return_type] || 'FaucetTransaction' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ExternalAddressesApi.request_external_faucet_funds", diff --git a/lib/coinbase/client/api/fund_api.rb b/lib/coinbase/client/api/fund_api.rb index 5bbe6a72..b868c803 100644 --- a/lib/coinbase/client/api/fund_api.rb +++ b/lib/coinbase/client/api/fund_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -80,7 +80,7 @@ def create_fund_operation_with_http_info(wallet_id, address_id, create_fund_oper return_type = opts[:debug_return_type] || 'FundOperation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"FundApi.create_fund_operation", @@ -160,7 +160,7 @@ def create_fund_quote_with_http_info(wallet_id, address_id, create_fund_quote_re return_type = opts[:debug_return_type] || 'FundQuote' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"FundApi.create_fund_quote", @@ -235,7 +235,7 @@ def get_fund_operation_with_http_info(wallet_id, address_id, fund_operation_id, return_type = opts[:debug_return_type] || 'FundOperation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"FundApi.get_fund_operation", @@ -314,7 +314,7 @@ def list_fund_operations_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'FundOperationList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"FundApi.list_fund_operations", diff --git a/lib/coinbase/client/api/mpc_wallet_stake_api.rb b/lib/coinbase/client/api/mpc_wallet_stake_api.rb index 40cedeb4..b57a8828 100644 --- a/lib/coinbase/client/api/mpc_wallet_stake_api.rb +++ b/lib/coinbase/client/api/mpc_wallet_stake_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -86,7 +86,7 @@ def broadcast_staking_operation_with_http_info(wallet_id, address_id, staking_op return_type = opts[:debug_return_type] || 'StakingOperation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"MPCWalletStakeApi.broadcast_staking_operation", @@ -166,7 +166,7 @@ def create_staking_operation_with_http_info(wallet_id, address_id, create_stakin return_type = opts[:debug_return_type] || 'StakingOperation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"MPCWalletStakeApi.create_staking_operation", @@ -241,7 +241,7 @@ def get_staking_operation_with_http_info(wallet_id, address_id, staking_operatio return_type = opts[:debug_return_type] || 'StakingOperation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"MPCWalletStakeApi.get_staking_operation", diff --git a/lib/coinbase/client/api/networks_api.rb b/lib/coinbase/client/api/networks_api.rb index c9726aa5..c9de56aa 100644 --- a/lib/coinbase/client/api/networks_api.rb +++ b/lib/coinbase/client/api/networks_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -63,7 +63,7 @@ def get_network_with_http_info(network_id, opts = {}) return_type = opts[:debug_return_type] || 'Network' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"NetworksApi.get_network", diff --git a/lib/coinbase/client/api/onchain_identity_api.rb b/lib/coinbase/client/api/onchain_identity_api.rb index 9852713b..e34428ad 100644 --- a/lib/coinbase/client/api/onchain_identity_api.rb +++ b/lib/coinbase/client/api/onchain_identity_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -86,7 +86,7 @@ def resolve_identity_by_address_with_http_info(network_id, address_id, opts = {} return_type = opts[:debug_return_type] || 'OnchainNameList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"OnchainIdentityApi.resolve_identity_by_address", diff --git a/lib/coinbase/client/api/reputation_api.rb b/lib/coinbase/client/api/reputation_api.rb index c88936d8..896516d3 100644 --- a/lib/coinbase/client/api/reputation_api.rb +++ b/lib/coinbase/client/api/reputation_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -69,7 +69,7 @@ def get_address_reputation_with_http_info(network_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'AddressReputation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ReputationApi.get_address_reputation", diff --git a/lib/coinbase/client/api/server_signers_api.rb b/lib/coinbase/client/api/server_signers_api.rb index d2aa3e3a..64f93b65 100644 --- a/lib/coinbase/client/api/server_signers_api.rb +++ b/lib/coinbase/client/api/server_signers_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -64,7 +64,7 @@ def create_server_signer_with_http_info(opts = {}) return_type = opts[:debug_return_type] || 'ServerSigner' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"ServerSignersApi.create_server_signer", @@ -127,7 +127,7 @@ def get_server_signer_with_http_info(server_signer_id, opts = {}) return_type = opts[:debug_return_type] || 'ServerSigner' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ServerSignersApi.get_server_signer", @@ -200,7 +200,7 @@ def list_server_signer_events_with_http_info(server_signer_id, opts = {}) return_type = opts[:debug_return_type] || 'ServerSignerEventList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"ServerSignersApi.list_server_signer_events", @@ -267,7 +267,7 @@ def list_server_signers_with_http_info(opts = {}) return_type = opts[:debug_return_type] || 'ServerSignerList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"ServerSignersApi.list_server_signers", @@ -337,7 +337,7 @@ def submit_server_signer_seed_event_result_with_http_info(server_signer_id, opts return_type = opts[:debug_return_type] || 'SeedCreationEventResult' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"ServerSignersApi.submit_server_signer_seed_event_result", @@ -407,7 +407,7 @@ def submit_server_signer_signature_event_result_with_http_info(server_signer_id, return_type = opts[:debug_return_type] || 'SignatureCreationEventResult' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"ServerSignersApi.submit_server_signer_signature_event_result", diff --git a/lib/coinbase/client/api/smart_contracts_api.rb b/lib/coinbase/client/api/smart_contracts_api.rb index e6e5f6b3..822bb910 100644 --- a/lib/coinbase/client/api/smart_contracts_api.rb +++ b/lib/coinbase/client/api/smart_contracts_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -80,7 +80,7 @@ def create_smart_contract_with_http_info(wallet_id, address_id, create_smart_con return_type = opts[:debug_return_type] || 'SmartContract' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"SmartContractsApi.create_smart_contract", @@ -166,7 +166,7 @@ def deploy_smart_contract_with_http_info(wallet_id, address_id, smart_contract_i return_type = opts[:debug_return_type] || 'SmartContract' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"SmartContractsApi.deploy_smart_contract", @@ -241,7 +241,7 @@ def get_smart_contract_with_http_info(wallet_id, address_id, smart_contract_id, return_type = opts[:debug_return_type] || 'SmartContract' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"SmartContractsApi.get_smart_contract", @@ -301,7 +301,7 @@ def list_smart_contracts_with_http_info(opts = {}) return_type = opts[:debug_return_type] || 'SmartContractList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"SmartContractsApi.list_smart_contracts", @@ -381,7 +381,7 @@ def read_contract_with_http_info(network_id, contract_address, read_contract_req return_type = opts[:debug_return_type] || 'SolidityValue' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"SmartContractsApi.read_contract", @@ -457,7 +457,7 @@ def register_smart_contract_with_http_info(network_id, contract_address, opts = return_type = opts[:debug_return_type] || 'SmartContract' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"SmartContractsApi.register_smart_contract", @@ -475,5 +475,81 @@ def register_smart_contract_with_http_info(network_id, contract_address, opts = end return data, status_code, headers end + + # Update a smart contract + # Update a smart contract + # @param network_id [String] The ID of the network to fetch. + # @param contract_address [String] EVM address of the smart contract (42 characters, including '0x', in lowercase) + # @param [Hash] opts the optional parameters + # @option opts [UpdateSmartContractRequest] :update_smart_contract_request + # @return [SmartContract] + def update_smart_contract(network_id, contract_address, opts = {}) + data, _status_code, _headers = update_smart_contract_with_http_info(network_id, contract_address, opts) + data + end + + # Update a smart contract + # Update a smart contract + # @param network_id [String] The ID of the network to fetch. + # @param contract_address [String] EVM address of the smart contract (42 characters, including '0x', in lowercase) + # @param [Hash] opts the optional parameters + # @option opts [UpdateSmartContractRequest] :update_smart_contract_request + # @return [Array<(SmartContract, Integer, Hash)>] SmartContract data, response status code and response headers + def update_smart_contract_with_http_info(network_id, contract_address, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SmartContractsApi.update_smart_contract ...' + end + # verify the required parameter 'network_id' is set + if @api_client.config.client_side_validation && network_id.nil? + fail ArgumentError, "Missing the required parameter 'network_id' when calling SmartContractsApi.update_smart_contract" + end + # verify the required parameter 'contract_address' is set + if @api_client.config.client_side_validation && contract_address.nil? + fail ArgumentError, "Missing the required parameter 'contract_address' when calling SmartContractsApi.update_smart_contract" + end + # resource path + local_var_path = '/v1/networks/{network_id}/smart_contracts/{contract_address}'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'contract_address' + '}', CGI.escape(contract_address.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'update_smart_contract_request']) + + # return_type + return_type = opts[:debug_return_type] || 'SmartContract' + + # auth_names + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] + + new_options = opts.merge( + :operation => :"SmartContractsApi.update_smart_contract", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SmartContractsApi#update_smart_contract\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/coinbase/client/api/stake_api.rb b/lib/coinbase/client/api/stake_api.rb index aee9c8a4..fbd428d4 100644 --- a/lib/coinbase/client/api/stake_api.rb +++ b/lib/coinbase/client/api/stake_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -68,7 +68,7 @@ def build_staking_operation_with_http_info(build_staking_operation_request, opts return_type = opts[:debug_return_type] || 'StakingOperation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"StakeApi.build_staking_operation", @@ -180,7 +180,7 @@ def fetch_historical_staking_balances_with_http_info(network_id, asset_id, addre return_type = opts[:debug_return_type] || 'FetchHistoricalStakingBalances200Response' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"StakeApi.fetch_historical_staking_balances", @@ -258,7 +258,7 @@ def fetch_staking_rewards_with_http_info(fetch_staking_rewards_request, opts = { return_type = opts[:debug_return_type] || 'FetchStakingRewards200Response' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"StakeApi.fetch_staking_rewards", @@ -333,7 +333,7 @@ def get_external_staking_operation_with_http_info(network_id, address_id, stakin return_type = opts[:debug_return_type] || 'StakingOperation' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"StakeApi.get_external_staking_operation", @@ -401,7 +401,7 @@ def get_staking_context_with_http_info(get_staking_context_request, opts = {}) return_type = opts[:debug_return_type] || 'StakingContext' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"StakeApi.get_staking_context", @@ -476,7 +476,7 @@ def get_validator_with_http_info(network_id, asset_id, validator_id, opts = {}) return_type = opts[:debug_return_type] || 'Validator' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"StakeApi.get_validator", @@ -558,7 +558,7 @@ def list_validators_with_http_info(network_id, asset_id, opts = {}) return_type = opts[:debug_return_type] || 'ValidatorList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"StakeApi.list_validators", diff --git a/lib/coinbase/client/api/trades_api.rb b/lib/coinbase/client/api/trades_api.rb index e4e13d8b..a8733997 100644 --- a/lib/coinbase/client/api/trades_api.rb +++ b/lib/coinbase/client/api/trades_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -86,7 +86,7 @@ def broadcast_trade_with_http_info(wallet_id, address_id, trade_id, broadcast_tr return_type = opts[:debug_return_type] || 'Trade' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"TradesApi.broadcast_trade", @@ -166,7 +166,7 @@ def create_trade_with_http_info(wallet_id, address_id, create_trade_request, opt return_type = opts[:debug_return_type] || 'Trade' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"TradesApi.create_trade", @@ -241,7 +241,7 @@ def get_trade_with_http_info(wallet_id, address_id, trade_id, opts = {}) return_type = opts[:debug_return_type] || 'Trade' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"TradesApi.get_trade", @@ -320,7 +320,7 @@ def list_trades_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'TradeList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"TradesApi.list_trades", diff --git a/lib/coinbase/client/api/transaction_history_api.rb b/lib/coinbase/client/api/transaction_history_api.rb index 64af84e3..c4f5f0b0 100644 --- a/lib/coinbase/client/api/transaction_history_api.rb +++ b/lib/coinbase/client/api/transaction_history_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -79,7 +79,7 @@ def list_address_transactions_with_http_info(network_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'AddressTransactionList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"TransactionHistoryApi.list_address_transactions", diff --git a/lib/coinbase/client/api/transfers_api.rb b/lib/coinbase/client/api/transfers_api.rb index 0d18b905..a190a3a5 100644 --- a/lib/coinbase/client/api/transfers_api.rb +++ b/lib/coinbase/client/api/transfers_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -24,11 +24,11 @@ def initialize(api_client = ApiClient.default) # @param wallet_id [String] The ID of the wallet the address belongs to # @param address_id [String] The ID of the address the transfer belongs to # @param transfer_id [String] The ID of the transfer to broadcast - # @param broadcast_transfer_request [BroadcastTransferRequest] + # @param broadcast_external_transfer_request [BroadcastExternalTransferRequest] # @param [Hash] opts the optional parameters # @return [Transfer] - def broadcast_transfer(wallet_id, address_id, transfer_id, broadcast_transfer_request, opts = {}) - data, _status_code, _headers = broadcast_transfer_with_http_info(wallet_id, address_id, transfer_id, broadcast_transfer_request, opts) + def broadcast_transfer(wallet_id, address_id, transfer_id, broadcast_external_transfer_request, opts = {}) + data, _status_code, _headers = broadcast_transfer_with_http_info(wallet_id, address_id, transfer_id, broadcast_external_transfer_request, opts) data end @@ -37,10 +37,10 @@ def broadcast_transfer(wallet_id, address_id, transfer_id, broadcast_transfer_re # @param wallet_id [String] The ID of the wallet the address belongs to # @param address_id [String] The ID of the address the transfer belongs to # @param transfer_id [String] The ID of the transfer to broadcast - # @param broadcast_transfer_request [BroadcastTransferRequest] + # @param broadcast_external_transfer_request [BroadcastExternalTransferRequest] # @param [Hash] opts the optional parameters # @return [Array<(Transfer, Integer, Hash)>] Transfer data, response status code and response headers - def broadcast_transfer_with_http_info(wallet_id, address_id, transfer_id, broadcast_transfer_request, opts = {}) + def broadcast_transfer_with_http_info(wallet_id, address_id, transfer_id, broadcast_external_transfer_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TransfersApi.broadcast_transfer ...' end @@ -56,9 +56,9 @@ def broadcast_transfer_with_http_info(wallet_id, address_id, transfer_id, broadc if @api_client.config.client_side_validation && transfer_id.nil? fail ArgumentError, "Missing the required parameter 'transfer_id' when calling TransfersApi.broadcast_transfer" end - # verify the required parameter 'broadcast_transfer_request' is set - if @api_client.config.client_side_validation && broadcast_transfer_request.nil? - fail ArgumentError, "Missing the required parameter 'broadcast_transfer_request' when calling TransfersApi.broadcast_transfer" + # verify the required parameter 'broadcast_external_transfer_request' is set + if @api_client.config.client_side_validation && broadcast_external_transfer_request.nil? + fail ArgumentError, "Missing the required parameter 'broadcast_external_transfer_request' when calling TransfersApi.broadcast_transfer" end # resource path local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/transfers/{transfer_id}/broadcast'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'transfer_id' + '}', CGI.escape(transfer_id.to_s)) @@ -80,13 +80,13 @@ def broadcast_transfer_with_http_info(wallet_id, address_id, transfer_id, broadc form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:debug_body] || @api_client.object_to_http_body(broadcast_transfer_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(broadcast_external_transfer_request) # return_type return_type = opts[:debug_return_type] || 'Transfer' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"TransfersApi.broadcast_transfer", @@ -166,7 +166,7 @@ def create_transfer_with_http_info(wallet_id, address_id, create_transfer_reques return_type = opts[:debug_return_type] || 'Transfer' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"TransfersApi.create_transfer", @@ -241,7 +241,7 @@ def get_transfer_with_http_info(wallet_id, address_id, transfer_id, opts = {}) return_type = opts[:debug_return_type] || 'Transfer' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"TransfersApi.get_transfer", @@ -320,7 +320,7 @@ def list_transfers_with_http_info(wallet_id, address_id, opts = {}) return_type = opts[:debug_return_type] || 'TransferList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"TransfersApi.list_transfers", diff --git a/lib/coinbase/client/api/users_api.rb b/lib/coinbase/client/api/users_api.rb index b2fbe00e..4c0898f5 100644 --- a/lib/coinbase/client/api/users_api.rb +++ b/lib/coinbase/client/api/users_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/api/wallets_api.rb b/lib/coinbase/client/api/wallets_api.rb index 485495cb..55fde466 100644 --- a/lib/coinbase/client/api/wallets_api.rb +++ b/lib/coinbase/client/api/wallets_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -64,7 +64,7 @@ def create_wallet_with_http_info(opts = {}) return_type = opts[:debug_return_type] || 'Wallet' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey'] new_options = opts.merge( :operation => :"WalletsApi.create_wallet", @@ -127,7 +127,7 @@ def get_wallet_with_http_info(wallet_id, opts = {}) return_type = opts[:debug_return_type] || 'Wallet' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WalletsApi.get_wallet", @@ -196,7 +196,7 @@ def get_wallet_balance_with_http_info(wallet_id, asset_id, opts = {}) return_type = opts[:debug_return_type] || 'Balance' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WalletsApi.get_wallet_balance", @@ -259,7 +259,7 @@ def list_wallet_balances_with_http_info(wallet_id, opts = {}) return_type = opts[:debug_return_type] || 'AddressBalanceList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WalletsApi.list_wallet_balances", @@ -326,7 +326,7 @@ def list_wallets_with_http_info(opts = {}) return_type = opts[:debug_return_type] || 'WalletList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WalletsApi.list_wallets", diff --git a/lib/coinbase/client/api/webhooks_api.rb b/lib/coinbase/client/api/webhooks_api.rb index eba94e66..6de86c8e 100644 --- a/lib/coinbase/client/api/webhooks_api.rb +++ b/lib/coinbase/client/api/webhooks_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -70,7 +70,7 @@ def create_wallet_webhook_with_http_info(wallet_id, opts = {}) return_type = opts[:debug_return_type] || 'Webhook' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WebhooksApi.create_wallet_webhook", @@ -134,7 +134,7 @@ def create_webhook_with_http_info(opts = {}) return_type = opts[:debug_return_type] || 'Webhook' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WebhooksApi.create_webhook", @@ -197,7 +197,7 @@ def delete_webhook_with_http_info(webhook_id, opts = {}) return_type = opts[:debug_return_type] # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WebhooksApi.delete_webhook", @@ -264,7 +264,7 @@ def list_webhooks_with_http_info(opts = {}) return_type = opts[:debug_return_type] || 'WebhookList' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WebhooksApi.list_webhooks", @@ -334,7 +334,7 @@ def update_webhook_with_http_info(webhook_id, opts = {}) return_type = opts[:debug_return_type] || 'Webhook' # auth_names - auth_names = opts[:debug_auth_names] || [] + auth_names = opts[:debug_auth_names] || ['apiKey', 'session'] new_options = opts.merge( :operation => :"WebhooksApi.update_webhook", diff --git a/lib/coinbase/client/api_client.rb b/lib/coinbase/client/api_client.rb index 5351423f..2844c8b3 100644 --- a/lib/coinbase/client/api_client.rb +++ b/lib/coinbase/client/api_client.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/api_error.rb b/lib/coinbase/client/api_error.rb index 71136cbe..4e169b7d 100644 --- a/lib/coinbase/client/api_error.rb +++ b/lib/coinbase/client/api_error.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/configuration.rb b/lib/coinbase/client/configuration.rb index 252fdc88..a68dc151 100644 --- a/lib/coinbase/client/configuration.rb +++ b/lib/coinbase/client/configuration.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -248,6 +248,20 @@ def basic_auth_token # Returns Auth Settings hash for api client. def auth_settings { + 'apiKey' => + { + type: 'api_key', + in: 'header', + key: 'Jwt', + value: api_key_with_prefix('Jwt') + }, + 'session' => + { + type: 'api_key', + in: 'header', + key: 'Jwt', + value: api_key_with_prefix('Jwt') + }, } end diff --git a/lib/coinbase/client/models/address.rb b/lib/coinbase/client/models/address.rb index 7e2d230a..ec4561f5 100644 --- a/lib/coinbase/client/models/address.rb +++ b/lib/coinbase/client/models/address.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/address_balance_list.rb b/lib/coinbase/client/models/address_balance_list.rb index 5f31e5d7..a6c2af81 100644 --- a/lib/coinbase/client/models/address_balance_list.rb +++ b/lib/coinbase/client/models/address_balance_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/address_historical_balance_list.rb b/lib/coinbase/client/models/address_historical_balance_list.rb index df3e91e8..203515c3 100644 --- a/lib/coinbase/client/models/address_historical_balance_list.rb +++ b/lib/coinbase/client/models/address_historical_balance_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/address_list.rb b/lib/coinbase/client/models/address_list.rb index 641df5e7..3b24d30e 100644 --- a/lib/coinbase/client/models/address_list.rb +++ b/lib/coinbase/client/models/address_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/address_reputation.rb b/lib/coinbase/client/models/address_reputation.rb index 6adb2ad1..39a47b1e 100644 --- a/lib/coinbase/client/models/address_reputation.rb +++ b/lib/coinbase/client/models/address_reputation.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/address_reputation_metadata.rb b/lib/coinbase/client/models/address_reputation_metadata.rb index 36c7bf44..2749bbf3 100644 --- a/lib/coinbase/client/models/address_reputation_metadata.rb +++ b/lib/coinbase/client/models/address_reputation_metadata.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/address_transaction_list.rb b/lib/coinbase/client/models/address_transaction_list.rb index 267c87d2..64fd96f1 100644 --- a/lib/coinbase/client/models/address_transaction_list.rb +++ b/lib/coinbase/client/models/address_transaction_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/asset.rb b/lib/coinbase/client/models/asset.rb index b6e16993..19433954 100644 --- a/lib/coinbase/client/models/asset.rb +++ b/lib/coinbase/client/models/asset.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/balance.rb b/lib/coinbase/client/models/balance.rb index 61badbcc..07345217 100644 --- a/lib/coinbase/client/models/balance.rb +++ b/lib/coinbase/client/models/balance.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/broadcast_contract_invocation_request.rb b/lib/coinbase/client/models/broadcast_contract_invocation_request.rb index b69c43cc..759a1cd2 100644 --- a/lib/coinbase/client/models/broadcast_contract_invocation_request.rb +++ b/lib/coinbase/client/models/broadcast_contract_invocation_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/broadcast_transfer_request.rb b/lib/coinbase/client/models/broadcast_external_transfer_request.rb similarity index 95% rename from lib/coinbase/client/models/broadcast_transfer_request.rb rename to lib/coinbase/client/models/broadcast_external_transfer_request.rb index b68f4be1..08305502 100644 --- a/lib/coinbase/client/models/broadcast_transfer_request.rb +++ b/lib/coinbase/client/models/broadcast_external_transfer_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -14,7 +14,7 @@ require 'time' module Coinbase::Client - class BroadcastTransferRequest + class BroadcastExternalTransferRequest # The hex-encoded signed payload of the transfer attr_accessor :signed_payload @@ -47,13 +47,13 @@ def self.openapi_nullable # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::BroadcastTransferRequest` initialize method" + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::BroadcastExternalTransferRequest` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - 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 + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::BroadcastExternalTransferRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } diff --git a/lib/coinbase/client/models/broadcast_staking_operation_request.rb b/lib/coinbase/client/models/broadcast_staking_operation_request.rb index eb82c471..0f3ebb0a 100644 --- a/lib/coinbase/client/models/broadcast_staking_operation_request.rb +++ b/lib/coinbase/client/models/broadcast_staking_operation_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/broadcast_trade_request.rb b/lib/coinbase/client/models/broadcast_trade_request.rb index eb966c65..434eae76 100644 --- a/lib/coinbase/client/models/broadcast_trade_request.rb +++ b/lib/coinbase/client/models/broadcast_trade_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/build_staking_operation_request.rb b/lib/coinbase/client/models/build_staking_operation_request.rb index 15ff48c2..e56ddd44 100644 --- a/lib/coinbase/client/models/build_staking_operation_request.rb +++ b/lib/coinbase/client/models/build_staking_operation_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/contract_event.rb b/lib/coinbase/client/models/contract_event.rb index 1c937363..c46ada62 100644 --- a/lib/coinbase/client/models/contract_event.rb +++ b/lib/coinbase/client/models/contract_event.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/contract_event_list.rb b/lib/coinbase/client/models/contract_event_list.rb index a525dcaf..3f956312 100644 --- a/lib/coinbase/client/models/contract_event_list.rb +++ b/lib/coinbase/client/models/contract_event_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/contract_invocation.rb b/lib/coinbase/client/models/contract_invocation.rb index a785e747..e46dad78 100644 --- a/lib/coinbase/client/models/contract_invocation.rb +++ b/lib/coinbase/client/models/contract_invocation.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/contract_invocation_list.rb b/lib/coinbase/client/models/contract_invocation_list.rb index 6dc2a133..6f11e4d8 100644 --- a/lib/coinbase/client/models/contract_invocation_list.rb +++ b/lib/coinbase/client/models/contract_invocation_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_address_request.rb b/lib/coinbase/client/models/create_address_request.rb index 9ee4372b..ae13c748 100644 --- a/lib/coinbase/client/models/create_address_request.rb +++ b/lib/coinbase/client/models/create_address_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_contract_invocation_request.rb b/lib/coinbase/client/models/create_contract_invocation_request.rb index c4f798ec..618b2072 100644 --- a/lib/coinbase/client/models/create_contract_invocation_request.rb +++ b/lib/coinbase/client/models/create_contract_invocation_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_external_transfer_request.rb b/lib/coinbase/client/models/create_external_transfer_request.rb new file mode 100644 index 00000000..73dc0ee9 --- /dev/null +++ b/lib/coinbase/client/models/create_external_transfer_request.rb @@ -0,0 +1,273 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha + +Generated by: https://openapi-generator.tech +Generator version: 7.10.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + class CreateExternalTransferRequest + # The amount to transfer + attr_accessor :amount + + # The ID of the asset to transfer. Can be an asset symbol or a token contract address. + attr_accessor :asset_id + + # The destination address, which can be a 0x address, Basename, or ENS name + attr_accessor :destination + + # Whether the transfer uses sponsored gas + attr_accessor :gasless + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'asset_id' => :'asset_id', + :'destination' => :'destination', + :'gasless' => :'gasless' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'String', + :'asset_id' => :'String', + :'destination' => :'String', + :'gasless' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::CreateExternalTransferRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::CreateExternalTransferRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end + + if attributes.key?(:'asset_id') + self.asset_id = attributes[:'asset_id'] + else + self.asset_id = nil + end + + if attributes.key?(:'destination') + self.destination = attributes[:'destination'] + else + self.destination = nil + end + + if attributes.key?(:'gasless') + self.gasless = attributes[:'gasless'] + else + self.gasless = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @amount.nil? + invalid_properties.push('invalid value for "amount", amount cannot be nil.') + end + + if @asset_id.nil? + invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.') + end + + if @destination.nil? + invalid_properties.push('invalid value for "destination", destination cannot be nil.') + end + + if @gasless.nil? + invalid_properties.push('invalid value for "gasless", gasless cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @amount.nil? + return false if @asset_id.nil? + return false if @destination.nil? + return false if @gasless.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + asset_id == o.asset_id && + destination == o.destination && + gasless == o.gasless + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, asset_id, destination, gasless].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/create_fund_operation_request.rb b/lib/coinbase/client/models/create_fund_operation_request.rb index aaa57b47..468d974f 100644 --- a/lib/coinbase/client/models/create_fund_operation_request.rb +++ b/lib/coinbase/client/models/create_fund_operation_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -18,7 +18,7 @@ class CreateFundOperationRequest # The amount of the asset to fund the address with in atomic units. attr_accessor :amount - # The ID of the asset to fund the address with. + # The ID of the asset to fund the address with. Can be an asset symbol or a token contract address. attr_accessor :asset_id # The Optional ID of the fund quote to fund the address with. If omitted we will generate a quote and immediately execute it. diff --git a/lib/coinbase/client/models/create_fund_quote_request.rb b/lib/coinbase/client/models/create_fund_quote_request.rb index cf171e84..347699ca 100644 --- a/lib/coinbase/client/models/create_fund_quote_request.rb +++ b/lib/coinbase/client/models/create_fund_quote_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -18,7 +18,7 @@ class CreateFundQuoteRequest # The amount of the asset to fund the address with in atomic units. attr_accessor :amount - # The ID of the asset to fund the address with. + # The ID of the asset to fund the address with. Can be an asset symbol alias or a token contract address. attr_accessor :asset_id # Attribute mapping from ruby-style variable name to JSON key. diff --git a/lib/coinbase/client/models/create_payload_signature_request.rb b/lib/coinbase/client/models/create_payload_signature_request.rb index ec433358..c74bba95 100644 --- a/lib/coinbase/client/models/create_payload_signature_request.rb +++ b/lib/coinbase/client/models/create_payload_signature_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_server_signer_request.rb b/lib/coinbase/client/models/create_server_signer_request.rb index e7bf0377..f1aeb1aa 100644 --- a/lib/coinbase/client/models/create_server_signer_request.rb +++ b/lib/coinbase/client/models/create_server_signer_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_smart_contract_request.rb b/lib/coinbase/client/models/create_smart_contract_request.rb index 98706287..b9ebe2ad 100644 --- a/lib/coinbase/client/models/create_smart_contract_request.rb +++ b/lib/coinbase/client/models/create_smart_contract_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_staking_operation_request.rb b/lib/coinbase/client/models/create_staking_operation_request.rb index 2598b4fa..248262a5 100644 --- a/lib/coinbase/client/models/create_staking_operation_request.rb +++ b/lib/coinbase/client/models/create_staking_operation_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_trade_request.rb b/lib/coinbase/client/models/create_trade_request.rb index 9dd16d76..8d9d8a8a 100644 --- a/lib/coinbase/client/models/create_trade_request.rb +++ b/lib/coinbase/client/models/create_trade_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_transfer_request.rb b/lib/coinbase/client/models/create_transfer_request.rb index f1798341..215e5cac 100644 --- a/lib/coinbase/client/models/create_transfer_request.rb +++ b/lib/coinbase/client/models/create_transfer_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -21,7 +21,7 @@ class CreateTransferRequest # The ID of the blockchain network attr_accessor :network_id - # The ID of the asset to transfer + # The ID of the asset to transfer. Can be an asset symbol or a token contract address. attr_accessor :asset_id # The destination address, which can be a 0x address, Basename, or ENS name diff --git a/lib/coinbase/client/models/create_wallet_request.rb b/lib/coinbase/client/models/create_wallet_request.rb index b7dc32ab..9cd3bd6f 100644 --- a/lib/coinbase/client/models/create_wallet_request.rb +++ b/lib/coinbase/client/models/create_wallet_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_wallet_request_wallet.rb b/lib/coinbase/client/models/create_wallet_request_wallet.rb index f0d451bc..a98f4a87 100644 --- a/lib/coinbase/client/models/create_wallet_request_wallet.rb +++ b/lib/coinbase/client/models/create_wallet_request_wallet.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_wallet_webhook_request.rb b/lib/coinbase/client/models/create_wallet_webhook_request.rb index 11febcb8..1000ccfa 100644 --- a/lib/coinbase/client/models/create_wallet_webhook_request.rb +++ b/lib/coinbase/client/models/create_wallet_webhook_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/create_webhook_request.rb b/lib/coinbase/client/models/create_webhook_request.rb index 6db3a98a..db041fbc 100644 --- a/lib/coinbase/client/models/create_webhook_request.rb +++ b/lib/coinbase/client/models/create_webhook_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/crypto_amount.rb b/lib/coinbase/client/models/crypto_amount.rb index 64ab664c..822de024 100644 --- a/lib/coinbase/client/models/crypto_amount.rb +++ b/lib/coinbase/client/models/crypto_amount.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/deploy_smart_contract_request.rb b/lib/coinbase/client/models/deploy_smart_contract_request.rb index 33e30cdd..eec9ea03 100644 --- a/lib/coinbase/client/models/deploy_smart_contract_request.rb +++ b/lib/coinbase/client/models/deploy_smart_contract_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/erc20_transfer_event.rb b/lib/coinbase/client/models/erc20_transfer_event.rb index e91d7efa..cc51bdf8 100644 --- a/lib/coinbase/client/models/erc20_transfer_event.rb +++ b/lib/coinbase/client/models/erc20_transfer_event.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/erc721_transfer_event.rb b/lib/coinbase/client/models/erc721_transfer_event.rb index 30089b4a..21bef5b6 100644 --- a/lib/coinbase/client/models/erc721_transfer_event.rb +++ b/lib/coinbase/client/models/erc721_transfer_event.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/error.rb b/lib/coinbase/client/models/error.rb index f47f1801..e21da672 100644 --- a/lib/coinbase/client/models/error.rb +++ b/lib/coinbase/client/models/error.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/ethereum_token_transfer.rb b/lib/coinbase/client/models/ethereum_token_transfer.rb index 87de3bcf..fff5ee20 100644 --- a/lib/coinbase/client/models/ethereum_token_transfer.rb +++ b/lib/coinbase/client/models/ethereum_token_transfer.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/ethereum_transaction.rb b/lib/coinbase/client/models/ethereum_transaction.rb index 2132eae1..84cf6600 100644 --- a/lib/coinbase/client/models/ethereum_transaction.rb +++ b/lib/coinbase/client/models/ethereum_transaction.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/ethereum_transaction_access.rb b/lib/coinbase/client/models/ethereum_transaction_access.rb index 3e0680db..ccae6561 100644 --- a/lib/coinbase/client/models/ethereum_transaction_access.rb +++ b/lib/coinbase/client/models/ethereum_transaction_access.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/ethereum_transaction_access_list.rb b/lib/coinbase/client/models/ethereum_transaction_access_list.rb index f40537f2..8d0a2d90 100644 --- a/lib/coinbase/client/models/ethereum_transaction_access_list.rb +++ b/lib/coinbase/client/models/ethereum_transaction_access_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/ethereum_transaction_flattened_trace.rb b/lib/coinbase/client/models/ethereum_transaction_flattened_trace.rb index 630164ed..c2df9298 100644 --- a/lib/coinbase/client/models/ethereum_transaction_flattened_trace.rb +++ b/lib/coinbase/client/models/ethereum_transaction_flattened_trace.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/ethereum_validator_metadata.rb b/lib/coinbase/client/models/ethereum_validator_metadata.rb index 9de82e96..d5c95787 100644 --- a/lib/coinbase/client/models/ethereum_validator_metadata.rb +++ b/lib/coinbase/client/models/ethereum_validator_metadata.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/faucet_transaction.rb b/lib/coinbase/client/models/faucet_transaction.rb index 87a7a266..26dd1459 100644 --- a/lib/coinbase/client/models/faucet_transaction.rb +++ b/lib/coinbase/client/models/faucet_transaction.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/feature_set.rb b/lib/coinbase/client/models/feature_set.rb index 87eb5778..f6f63a07 100644 --- a/lib/coinbase/client/models/feature_set.rb +++ b/lib/coinbase/client/models/feature_set.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb b/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb index a84af518..d3805e62 100644 --- a/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +++ b/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/fetch_staking_rewards200_response.rb b/lib/coinbase/client/models/fetch_staking_rewards200_response.rb index 04684e23..3dd74380 100644 --- a/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +++ b/lib/coinbase/client/models/fetch_staking_rewards200_response.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/fetch_staking_rewards_request.rb b/lib/coinbase/client/models/fetch_staking_rewards_request.rb index b17046f8..139cdba8 100644 --- a/lib/coinbase/client/models/fetch_staking_rewards_request.rb +++ b/lib/coinbase/client/models/fetch_staking_rewards_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/fiat_amount.rb b/lib/coinbase/client/models/fiat_amount.rb index d2782bd7..ff23702a 100644 --- a/lib/coinbase/client/models/fiat_amount.rb +++ b/lib/coinbase/client/models/fiat_amount.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/fund_operation.rb b/lib/coinbase/client/models/fund_operation.rb index 2c797907..88e9491f 100644 --- a/lib/coinbase/client/models/fund_operation.rb +++ b/lib/coinbase/client/models/fund_operation.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/fund_operation_fees.rb b/lib/coinbase/client/models/fund_operation_fees.rb index 99bcd0d1..cb85e1c0 100644 --- a/lib/coinbase/client/models/fund_operation_fees.rb +++ b/lib/coinbase/client/models/fund_operation_fees.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/fund_operation_list.rb b/lib/coinbase/client/models/fund_operation_list.rb index c7789dad..2aeb8e77 100644 --- a/lib/coinbase/client/models/fund_operation_list.rb +++ b/lib/coinbase/client/models/fund_operation_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/fund_quote.rb b/lib/coinbase/client/models/fund_quote.rb index 07eaf115..f5d0bd4a 100644 --- a/lib/coinbase/client/models/fund_quote.rb +++ b/lib/coinbase/client/models/fund_quote.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/get_staking_context_request.rb b/lib/coinbase/client/models/get_staking_context_request.rb index 5edda018..b9f57b88 100644 --- a/lib/coinbase/client/models/get_staking_context_request.rb +++ b/lib/coinbase/client/models/get_staking_context_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/historical_balance.rb b/lib/coinbase/client/models/historical_balance.rb index fc88f20f..2cf90b15 100644 --- a/lib/coinbase/client/models/historical_balance.rb +++ b/lib/coinbase/client/models/historical_balance.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/multi_token_contract_options.rb b/lib/coinbase/client/models/multi_token_contract_options.rb index abab258f..3dcab346 100644 --- a/lib/coinbase/client/models/multi_token_contract_options.rb +++ b/lib/coinbase/client/models/multi_token_contract_options.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/network.rb b/lib/coinbase/client/models/network.rb index d66729ab..aebad0ec 100644 --- a/lib/coinbase/client/models/network.rb +++ b/lib/coinbase/client/models/network.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/network_identifier.rb b/lib/coinbase/client/models/network_identifier.rb index bdd04ba7..5cf342f5 100644 --- a/lib/coinbase/client/models/network_identifier.rb +++ b/lib/coinbase/client/models/network_identifier.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/nft_contract_options.rb b/lib/coinbase/client/models/nft_contract_options.rb index 142d245c..0bc8c80c 100644 --- a/lib/coinbase/client/models/nft_contract_options.rb +++ b/lib/coinbase/client/models/nft_contract_options.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/onchain_name.rb b/lib/coinbase/client/models/onchain_name.rb index 1dd86d45..47a18a37 100644 --- a/lib/coinbase/client/models/onchain_name.rb +++ b/lib/coinbase/client/models/onchain_name.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/onchain_name_list.rb b/lib/coinbase/client/models/onchain_name_list.rb index 57b72eb0..bf90575d 100644 --- a/lib/coinbase/client/models/onchain_name_list.rb +++ b/lib/coinbase/client/models/onchain_name_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/payload_signature.rb b/lib/coinbase/client/models/payload_signature.rb index fe9df04f..fe85fbc4 100644 --- a/lib/coinbase/client/models/payload_signature.rb +++ b/lib/coinbase/client/models/payload_signature.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/payload_signature_list.rb b/lib/coinbase/client/models/payload_signature_list.rb index ea692d0f..6e842bce 100644 --- a/lib/coinbase/client/models/payload_signature_list.rb +++ b/lib/coinbase/client/models/payload_signature_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/read_contract_request.rb b/lib/coinbase/client/models/read_contract_request.rb index 723093c3..2cf0e99d 100644 --- a/lib/coinbase/client/models/read_contract_request.rb +++ b/lib/coinbase/client/models/read_contract_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/register_smart_contract_request.rb b/lib/coinbase/client/models/register_smart_contract_request.rb index 73c9f7ca..1329cf52 100644 --- a/lib/coinbase/client/models/register_smart_contract_request.rb +++ b/lib/coinbase/client/models/register_smart_contract_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -72,8 +72,6 @@ def initialize(attributes = {}) if attributes.key?(:'contract_name') self.contract_name = attributes[:'contract_name'] - else - self.contract_name = nil end end @@ -86,8 +84,8 @@ def list_invalid_properties invalid_properties.push('invalid value for "abi", abi cannot be nil.') end - if @contract_name.nil? - invalid_properties.push('invalid value for "contract_name", contract_name cannot be nil.') + if !@contract_name.nil? && @contract_name.to_s.length > 100 + invalid_properties.push('invalid value for "contract_name", the character length must be smaller than or equal to 100.') end invalid_properties @@ -98,10 +96,24 @@ def list_invalid_properties def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @abi.nil? - return false if @contract_name.nil? + return false if !@contract_name.nil? && @contract_name.to_s.length > 100 true end + # Custom attribute writer method with validation + # @param [Object] contract_name Value to be assigned + def contract_name=(contract_name) + if contract_name.nil? + fail ArgumentError, 'contract_name cannot be nil' + end + + if contract_name.to_s.length > 100 + fail ArgumentError, 'invalid value for "contract_name", the character length must be smaller than or equal to 100.' + end + + @contract_name = contract_name + end + # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/lib/coinbase/client/models/seed_creation_event.rb b/lib/coinbase/client/models/seed_creation_event.rb index a2f474f2..b25a3eff 100644 --- a/lib/coinbase/client/models/seed_creation_event.rb +++ b/lib/coinbase/client/models/seed_creation_event.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/seed_creation_event_result.rb b/lib/coinbase/client/models/seed_creation_event_result.rb index a6c79557..7b015ecf 100644 --- a/lib/coinbase/client/models/seed_creation_event_result.rb +++ b/lib/coinbase/client/models/seed_creation_event_result.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/server_signer.rb b/lib/coinbase/client/models/server_signer.rb index 9f405018..26b55794 100644 --- a/lib/coinbase/client/models/server_signer.rb +++ b/lib/coinbase/client/models/server_signer.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/server_signer_event.rb b/lib/coinbase/client/models/server_signer_event.rb index 24e02c85..43581730 100644 --- a/lib/coinbase/client/models/server_signer_event.rb +++ b/lib/coinbase/client/models/server_signer_event.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/server_signer_event_event.rb b/lib/coinbase/client/models/server_signer_event_event.rb index 7fbe5236..8db13d18 100644 --- a/lib/coinbase/client/models/server_signer_event_event.rb +++ b/lib/coinbase/client/models/server_signer_event_event.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/server_signer_event_list.rb b/lib/coinbase/client/models/server_signer_event_list.rb index 91fb04da..f2802ca3 100644 --- a/lib/coinbase/client/models/server_signer_event_list.rb +++ b/lib/coinbase/client/models/server_signer_event_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/server_signer_list.rb b/lib/coinbase/client/models/server_signer_list.rb index bf15e068..15e399e4 100644 --- a/lib/coinbase/client/models/server_signer_list.rb +++ b/lib/coinbase/client/models/server_signer_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/signature_creation_event.rb b/lib/coinbase/client/models/signature_creation_event.rb index 65749713..77aeee6b 100644 --- a/lib/coinbase/client/models/signature_creation_event.rb +++ b/lib/coinbase/client/models/signature_creation_event.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/signature_creation_event_result.rb b/lib/coinbase/client/models/signature_creation_event_result.rb index fed1aeb5..00b0ec6f 100644 --- a/lib/coinbase/client/models/signature_creation_event_result.rb +++ b/lib/coinbase/client/models/signature_creation_event_result.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb b/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb index ee090ba8..df1e008a 100644 --- a/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb +++ b/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/smart_contract.rb b/lib/coinbase/client/models/smart_contract.rb index fac28e4e..f726014a 100644 --- a/lib/coinbase/client/models/smart_contract.rb +++ b/lib/coinbase/client/models/smart_contract.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/smart_contract_activity_event.rb b/lib/coinbase/client/models/smart_contract_activity_event.rb index 1dba2a07..3fd1b855 100644 --- a/lib/coinbase/client/models/smart_contract_activity_event.rb +++ b/lib/coinbase/client/models/smart_contract_activity_event.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/smart_contract_list.rb b/lib/coinbase/client/models/smart_contract_list.rb index a0e95b5d..d8b91059 100644 --- a/lib/coinbase/client/models/smart_contract_list.rb +++ b/lib/coinbase/client/models/smart_contract_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/smart_contract_options.rb b/lib/coinbase/client/models/smart_contract_options.rb index 4ca54860..3cd642d3 100644 --- a/lib/coinbase/client/models/smart_contract_options.rb +++ b/lib/coinbase/client/models/smart_contract_options.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/smart_contract_type.rb b/lib/coinbase/client/models/smart_contract_type.rb index f41bbd72..f19fb790 100644 --- a/lib/coinbase/client/models/smart_contract_type.rb +++ b/lib/coinbase/client/models/smart_contract_type.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/solidity_value.rb b/lib/coinbase/client/models/solidity_value.rb index ee688923..3a48f3e3 100644 --- a/lib/coinbase/client/models/solidity_value.rb +++ b/lib/coinbase/client/models/solidity_value.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/sponsored_send.rb b/lib/coinbase/client/models/sponsored_send.rb index 3621c9a1..f9a78d3b 100644 --- a/lib/coinbase/client/models/sponsored_send.rb +++ b/lib/coinbase/client/models/sponsored_send.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/staking_balance.rb b/lib/coinbase/client/models/staking_balance.rb index 8138b63b..d6902347 100644 --- a/lib/coinbase/client/models/staking_balance.rb +++ b/lib/coinbase/client/models/staking_balance.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/staking_context.rb b/lib/coinbase/client/models/staking_context.rb index 886b9168..4f6f9ba4 100644 --- a/lib/coinbase/client/models/staking_context.rb +++ b/lib/coinbase/client/models/staking_context.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/staking_context_context.rb b/lib/coinbase/client/models/staking_context_context.rb index e30e967b..d0c29bbf 100644 --- a/lib/coinbase/client/models/staking_context_context.rb +++ b/lib/coinbase/client/models/staking_context_context.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/staking_operation.rb b/lib/coinbase/client/models/staking_operation.rb index 957ee980..582adb35 100644 --- a/lib/coinbase/client/models/staking_operation.rb +++ b/lib/coinbase/client/models/staking_operation.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/staking_operation_metadata.rb b/lib/coinbase/client/models/staking_operation_metadata.rb index fe363328..62d81736 100644 --- a/lib/coinbase/client/models/staking_operation_metadata.rb +++ b/lib/coinbase/client/models/staking_operation_metadata.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/staking_reward.rb b/lib/coinbase/client/models/staking_reward.rb index a0294853..1a2956bf 100644 --- a/lib/coinbase/client/models/staking_reward.rb +++ b/lib/coinbase/client/models/staking_reward.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/staking_reward_format.rb b/lib/coinbase/client/models/staking_reward_format.rb index 0192ebf1..640932e8 100644 --- a/lib/coinbase/client/models/staking_reward_format.rb +++ b/lib/coinbase/client/models/staking_reward_format.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/staking_reward_usd_value.rb b/lib/coinbase/client/models/staking_reward_usd_value.rb index fe302155..3fd45c9a 100644 --- a/lib/coinbase/client/models/staking_reward_usd_value.rb +++ b/lib/coinbase/client/models/staking_reward_usd_value.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/token_contract_options.rb b/lib/coinbase/client/models/token_contract_options.rb index 23f4f283..aa9b045d 100644 --- a/lib/coinbase/client/models/token_contract_options.rb +++ b/lib/coinbase/client/models/token_contract_options.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/token_transfer_type.rb b/lib/coinbase/client/models/token_transfer_type.rb index f11a7e5a..5a37abe4 100644 --- a/lib/coinbase/client/models/token_transfer_type.rb +++ b/lib/coinbase/client/models/token_transfer_type.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/trade.rb b/lib/coinbase/client/models/trade.rb index 4623a974..c1682612 100644 --- a/lib/coinbase/client/models/trade.rb +++ b/lib/coinbase/client/models/trade.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/trade_list.rb b/lib/coinbase/client/models/trade_list.rb index b2753265..d39c456e 100644 --- a/lib/coinbase/client/models/trade_list.rb +++ b/lib/coinbase/client/models/trade_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/transaction.rb b/lib/coinbase/client/models/transaction.rb index c28c5b8f..8458d614 100644 --- a/lib/coinbase/client/models/transaction.rb +++ b/lib/coinbase/client/models/transaction.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/transaction_content.rb b/lib/coinbase/client/models/transaction_content.rb index 470b9689..884cffa0 100644 --- a/lib/coinbase/client/models/transaction_content.rb +++ b/lib/coinbase/client/models/transaction_content.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/transaction_type.rb b/lib/coinbase/client/models/transaction_type.rb index 076605ec..9fb2dd09 100644 --- a/lib/coinbase/client/models/transaction_type.rb +++ b/lib/coinbase/client/models/transaction_type.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/transfer.rb b/lib/coinbase/client/models/transfer.rb index 7a0123e8..21358007 100644 --- a/lib/coinbase/client/models/transfer.rb +++ b/lib/coinbase/client/models/transfer.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end @@ -31,7 +31,7 @@ class Transfer # The amount in the atomic units of the asset attr_accessor :amount - # The ID of the asset being transferred + # The ID of the asset being transferred. Use `asset.asset_id` instead. attr_accessor :asset_id attr_accessor :asset @@ -52,34 +52,11 @@ class Transfer # The hash of the transfer transaction attr_accessor :transaction_hash - # The status of the transfer attr_accessor :status # Whether the transfer uses sponsored gas attr_accessor :gasless - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -283,22 +260,10 @@ def valid? return false if @asset_id.nil? return false if @asset.nil? return false if @transfer_id.nil? - status_validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed", "unknown_default_open_api"]) - return false unless status_validator.valid?(@status) return false if @gasless.nil? true end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] status Object to be assigned - def status=(status) - validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed", "unknown_default_open_api"]) - unless validator.valid?(status) - fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." - end - @status = status - end - # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/lib/coinbase/client/models/transfer_list.rb b/lib/coinbase/client/models/transfer_list.rb index 4ff23e36..1742f380 100644 --- a/lib/coinbase/client/models/transfer_list.rb +++ b/lib/coinbase/client/models/transfer_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/update_smart_contract_request.rb b/lib/coinbase/client/models/update_smart_contract_request.rb new file mode 100644 index 00000000..09738e71 --- /dev/null +++ b/lib/coinbase/client/models/update_smart_contract_request.rb @@ -0,0 +1,245 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha + +Generated by: https://openapi-generator.tech +Generator version: 7.10.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # Smart Contract data to be updated + class UpdateSmartContractRequest + # ABI of the smart contract + attr_accessor :abi + + # Name of the smart contract + attr_accessor :contract_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'abi' => :'abi', + :'contract_name' => :'contract_name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'abi' => :'String', + :'contract_name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::UpdateSmartContractRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::UpdateSmartContractRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'abi') + self.abi = attributes[:'abi'] + end + + if attributes.key?(:'contract_name') + self.contract_name = attributes[:'contract_name'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@contract_name.nil? && @contract_name.to_s.length > 100 + invalid_properties.push('invalid value for "contract_name", the character length must be smaller than or equal to 100.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@contract_name.nil? && @contract_name.to_s.length > 100 + true + end + + # Custom attribute writer method with validation + # @param [Object] contract_name Value to be assigned + def contract_name=(contract_name) + if contract_name.nil? + fail ArgumentError, 'contract_name cannot be nil' + end + + if contract_name.to_s.length > 100 + fail ArgumentError, 'invalid value for "contract_name", the character length must be smaller than or equal to 100.' + end + + @contract_name = contract_name + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + abi == o.abi && + contract_name == o.contract_name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [abi, contract_name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/update_webhook_request.rb b/lib/coinbase/client/models/update_webhook_request.rb index 25c850d5..e1fdd626 100644 --- a/lib/coinbase/client/models/update_webhook_request.rb +++ b/lib/coinbase/client/models/update_webhook_request.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/user.rb b/lib/coinbase/client/models/user.rb index 1457faa5..b965d35a 100644 --- a/lib/coinbase/client/models/user.rb +++ b/lib/coinbase/client/models/user.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/validator.rb b/lib/coinbase/client/models/validator.rb index 4984b6a1..fead08a1 100644 --- a/lib/coinbase/client/models/validator.rb +++ b/lib/coinbase/client/models/validator.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/validator_details.rb b/lib/coinbase/client/models/validator_details.rb index 9ab1bde6..4590d46c 100644 --- a/lib/coinbase/client/models/validator_details.rb +++ b/lib/coinbase/client/models/validator_details.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/validator_list.rb b/lib/coinbase/client/models/validator_list.rb index 8a99dcaf..e5c26995 100644 --- a/lib/coinbase/client/models/validator_list.rb +++ b/lib/coinbase/client/models/validator_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/validator_status.rb b/lib/coinbase/client/models/validator_status.rb index 86c17282..515f0e37 100644 --- a/lib/coinbase/client/models/validator_status.rb +++ b/lib/coinbase/client/models/validator_status.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/wallet.rb b/lib/coinbase/client/models/wallet.rb index 85f0a6f2..93699623 100644 --- a/lib/coinbase/client/models/wallet.rb +++ b/lib/coinbase/client/models/wallet.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/wallet_list.rb b/lib/coinbase/client/models/wallet_list.rb index 11e2565e..bc2ac9a4 100644 --- a/lib/coinbase/client/models/wallet_list.rb +++ b/lib/coinbase/client/models/wallet_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/webhook.rb b/lib/coinbase/client/models/webhook.rb index ca3d666b..e08d85e4 100644 --- a/lib/coinbase/client/models/webhook.rb +++ b/lib/coinbase/client/models/webhook.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/webhook_event_filter.rb b/lib/coinbase/client/models/webhook_event_filter.rb index 204b1496..822e57c3 100644 --- a/lib/coinbase/client/models/webhook_event_filter.rb +++ b/lib/coinbase/client/models/webhook_event_filter.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/webhook_event_type.rb b/lib/coinbase/client/models/webhook_event_type.rb index 9ab7ffad..1ddb6715 100644 --- a/lib/coinbase/client/models/webhook_event_type.rb +++ b/lib/coinbase/client/models/webhook_event_type.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/webhook_event_type_filter.rb b/lib/coinbase/client/models/webhook_event_type_filter.rb index c8dd017b..6ba5e07a 100644 --- a/lib/coinbase/client/models/webhook_event_type_filter.rb +++ b/lib/coinbase/client/models/webhook_event_type_filter.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/webhook_list.rb b/lib/coinbase/client/models/webhook_list.rb index 6b575061..4f8df750 100644 --- a/lib/coinbase/client/models/webhook_list.rb +++ b/lib/coinbase/client/models/webhook_list.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/webhook_smart_contract_event_filter.rb b/lib/coinbase/client/models/webhook_smart_contract_event_filter.rb index b0e54e18..01e05e8f 100644 --- a/lib/coinbase/client/models/webhook_smart_contract_event_filter.rb +++ b/lib/coinbase/client/models/webhook_smart_contract_event_filter.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/models/webhook_wallet_activity_filter.rb b/lib/coinbase/client/models/webhook_wallet_activity_filter.rb index 7d200d5f..1479ed79 100644 --- a/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +++ b/lib/coinbase/client/models/webhook_wallet_activity_filter.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/client/version.rb b/lib/coinbase/client/version.rb index 0eff73f9..164d1705 100644 --- a/lib/coinbase/client/version.rb +++ b/lib/coinbase/client/version.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: 0.0.1-alpha Generated by: https://openapi-generator.tech -Generator version: 7.9.0 +Generator version: 7.10.0 =end diff --git a/lib/coinbase/errors.rb b/lib/coinbase/errors.rb index d1b6562a..44e431c4 100644 --- a/lib/coinbase/errors.rb +++ b/lib/coinbase/errors.rb @@ -84,6 +84,14 @@ def initialize(msg = 'Transaction must be signed') end end + # An error raised when attempting to manage an external contract on-chain, + # e.g. sign the deployment tx, deploy the contract, etc... + class ManageExternalContractError < StandardError + def initialize(action = 'manage') + super("Cannot #{action} external smart contract") + end + end + # An error raised when an address attempts to sign a transaction without a private key. class AddressCannotSignError < StandardError def initialize(msg = 'Address cannot sign transaction without private key loaded') diff --git a/lib/coinbase/smart_contract.rb b/lib/coinbase/smart_contract.rb index bd7ae5c7..be245fd8 100644 --- a/lib/coinbase/smart_contract.rb +++ b/lib/coinbase/smart_contract.rb @@ -2,257 +2,311 @@ module Coinbase # A representation of a SmartContract on the blockchain. + # rubocop:disable Metrics/ClassLength class SmartContract - # Returns a list of ContractEvents for the provided network, contract, and event details. - # @param network_id [Symbol] The network ID - # @param protocol_name [String] The protocol name - # @param contract_address [String] The contract address - # @param contract_name [String] The contract name - # @param event_name [String] The event name - # @param from_block_height [Integer] The start block height - # @param to_block_height [Integer] The end block height - # @return [Enumerable] The contract events - def self.list_events( - network_id:, - protocol_name:, - contract_address:, - contract_name:, - event_name:, - from_block_height:, - to_block_height: - ) - Coinbase::Pagination.enumerate( - lambda { |page| - list_events_page( - network_id, - protocol_name, - contract_address, - contract_name, - event_name, - from_block_height, - to_block_height, - page - ) - } - ) do |contract_event| - Coinbase::ContractEvent.new(contract_event) + class << self + # Returns a list of ContractEvents for the provided network, contract, and event details. + # @param network_id [Symbol] The network ID + # @param protocol_name [String] The protocol name + # @param contract_address [String] The contract address + # @param contract_name [String] The contract name + # @param event_name [String] The event name + # @param from_block_height [Integer] The start block height + # @param to_block_height [Integer] The end block height + # @return [Enumerable] The contract events + def list_events( + network_id:, + protocol_name:, + contract_address:, + contract_name:, + event_name:, + from_block_height:, + to_block_height: + ) + Coinbase::Pagination.enumerate( + lambda { |page| + list_events_page( + network_id, + protocol_name, + contract_address, + contract_name, + event_name, + from_block_height, + to_block_height, + page + ) + } + ) do |contract_event| + Coinbase::ContractEvent.new(contract_event) + end end - end - # Creates a new ERC20 token contract, that can subsequently be deployed to - # the blockchain. - # @param address_id [String] The address ID of deployer - # @param wallet_id [String] The wallet ID of the deployer - # @param name [String] The name of the token - # @param symbol [String] The symbol of the token - # @param total_supply [String] The total supply of the token, denominate in whole units. - # @return [SmartContract] The new ERC20 Token SmartContract object - def self.create_token_contract( - address_id:, - wallet_id:, - name:, - symbol:, - total_supply: - ) - contract = Coinbase.call_api do - smart_contracts_api.create_smart_contract( - wallet_id, - address_id, - { - type: Coinbase::Client::SmartContractType::ERC20, - options: Coinbase::Client::TokenContractOptions.new( - name: name, - symbol: symbol, - total_supply: BigDecimal(total_supply).to_i.to_s - ).to_body - } - ) + # Creates a new ERC20 token contract, that can subsequently be deployed to + # the blockchain. + # @param address_id [String] The address ID of deployer + # @param wallet_id [String] The wallet ID of the deployer + # @param name [String] The name of the token + # @param symbol [String] The symbol of the token + # @param total_supply [String] The total supply of the token, denominate in whole units. + # @return [SmartContract] The new ERC20 Token SmartContract object + def create_token_contract( + address_id:, + wallet_id:, + name:, + symbol:, + total_supply: + ) + contract = Coinbase.call_api do + smart_contracts_api.create_smart_contract( + wallet_id, + address_id, + { + type: Coinbase::Client::SmartContractType::ERC20, + options: Coinbase::Client::TokenContractOptions.new( + name: name, + symbol: symbol, + total_supply: BigDecimal(total_supply).to_i.to_s + ).to_body + } + ) + end + + new(contract) end - new(contract) - end + # Creates a new ERC721 token contract, that can subsequently be deployed to + # the blockchain. + # @param address_id [String] The address ID of deployer + # @param wallet_id [String] The wallet ID of the deployer + # @param name [String] The name of the token + # @param symbol [String] The symbol of the token + # @param base_uri [String] The base URI for the token metadata + # @return [SmartContract] The new ERC721 Token SmartContract object + def create_nft_contract( + address_id:, + wallet_id:, + name:, + symbol:, + base_uri: + ) + contract = Coinbase.call_api do + smart_contracts_api.create_smart_contract( + wallet_id, + address_id, + { + type: Coinbase::Client::SmartContractType::ERC721, + options: Coinbase::Client::NFTContractOptions.new( + name: name, + symbol: symbol, + base_uri: base_uri + ).to_body + } + ) + end - # Creates a new ERC721 token contract, that can subsequently be deployed to - # the blockchain. - # @param address_id [String] The address ID of deployer - # @param wallet_id [String] The wallet ID of the deployer - # @param name [String] The name of the token - # @param symbol [String] The symbol of the token - # @param base_uri [String] The base URI for the token metadata - # @return [SmartContract] The new ERC721 Token SmartContract object - def self.create_nft_contract( - address_id:, - wallet_id:, - name:, - symbol:, - base_uri: - ) - contract = Coinbase.call_api do - smart_contracts_api.create_smart_contract( - wallet_id, - address_id, - { - type: Coinbase::Client::SmartContractType::ERC721, - options: Coinbase::Client::NFTContractOptions.new( - name: name, - symbol: symbol, - base_uri: base_uri - ).to_body - } - ) + new(contract) end - new(contract) - end + # Creates a new ERC1155 multi-token contract, that can subsequently be deployed to + # the blockchain. + # @param address_id [String] The address ID of deployer + # @param wallet_id [String] The wallet ID of the deployer + # @param uri [String] The URI for the token metadata + # @return [SmartContract] The new ERC1155 Multi-Token SmartContract object + def create_multi_token_contract( + address_id:, + wallet_id:, + uri: + ) + contract = Coinbase.call_api do + smart_contracts_api.create_smart_contract( + wallet_id, + address_id, + { + type: Coinbase::Client::SmartContractType::ERC1155, + options: Coinbase::Client::MultiTokenContractOptions.new( + uri: uri + ).to_body + } + ) + end - # Creates a new ERC1155 multi-token contract, that can subsequently be deployed to - # the blockchain. - # @param address_id [String] The address ID of deployer - # @param wallet_id [String] The wallet ID of the deployer - # @param uri [String] The URI for the token metadata - # @return [SmartContract] The new ERC1155 Multi-Token SmartContract object - def self.create_multi_token_contract( - address_id:, - wallet_id:, - uri: - ) - contract = Coinbase.call_api do - smart_contracts_api.create_smart_contract( - wallet_id, - address_id, - { - type: Coinbase::Client::SmartContractType::ERC1155, - options: Coinbase::Client::MultiTokenContractOptions.new( - uri: uri - ).to_body - } - ) + new(contract) end - new(contract) - end + # Registers an externally deployed smart contract with the API. + # @param contract_address [String] The address of the deployed contract + # @param abi [Array, String] The ABI of the contract + # @param network [Coinbase::Network, Symbol] The Network or Network ID the contract is deployed on + # @param name [String, nil] The optional name of the contract + def register( + contract_address:, + abi:, + name: nil, + network: Coinbase.default_network + ) + network = Coinbase::Network.from_id(network) - # Reads data from a deployed smart contract. - # - # @param network [Coinbase::Network, Symbol] The Network or Network ID of the Asset - # @param contract_address [String] The address of the deployed contract - # @param method [String] The name of the method to call on the contract - # @param abi [Array, nil] The ABI of the contract. If nil, the method will attempt to use a cached ABI - # @param args [Hash] The arguments to pass to the contract method. - # The keys should be the argument names, and the values should be the argument values. - # @return [Object] The result of the contract call, converted to an appropriate Ruby type - # @raise [Coinbase::ApiError] If there's an error in the API call - def self.read( - contract_address:, - method:, - network: Coinbase.default_network, - abi: nil, - args: {} - ) - network = Coinbase::Network.from_id(network) - - response = Coinbase.call_api do - smart_contracts_api.read_contract( - network.normalized_id, - contract_address, - { - method: method, - args: (args || {}).to_json, - abi: abi&.to_json - }.compact - ) + normalized_abi = normalize_abi(abi) + + smart_contract = Coinbase.call_api do + smart_contracts_api.register_smart_contract( + network.normalized_id, + contract_address, + register_smart_contract_request: { + abi: normalized_abi.to_json, + contract_name: name + }.compact + ) + end + + new(smart_contract) end - convert_solidity_value(response) - end + # Reads data from a deployed smart contract. + # + # @param network [Coinbase::Network, Symbol] The Network or Network ID of the Asset + # @param contract_address [String] The address of the deployed contract + # @param method [String] The name of the method to call on the contract + # @param abi [Array, nil] The ABI of the contract. If nil, the method will attempt to use a cached ABI + # @param args [Hash] The arguments to pass to the contract method. + # The keys should be the argument names, and the values should be the argument values. + # @return [Object] The result of the contract call, converted to an appropriate Ruby type + # @raise [Coinbase::ApiError] If there's an error in the API call + def read( + contract_address:, + method:, + network: Coinbase.default_network, + abi: nil, + args: {} + ) + network = Coinbase::Network.from_id(network) - # Converts a Solidity value to an appropriate Ruby type. - # - # @param solidity_value [Coinbase::Client::SolidityValue] The Solidity value to convert - # @return [Object] The converted Ruby value - # @raise [ArgumentError] If an unsupported Solidity type is encountered - # - # This method handles the following Solidity types: - # - Integers (uint8, uint16, uint32, uint64, uint128, uint256, int8, int16, int32, int64, int128, int256) - # - Address - # - String - # - Bytes (including fixed-size byte arrays) - # - Boolean - # - Array - # - Tuple (converted to a Hash) - # - # For complex types like arrays and tuples, the method recursively converts nested values. - def self.convert_solidity_value(solidity_value) - return nil if solidity_value.nil? - - type = solidity_value.type - value = solidity_value.value - values = solidity_value.values - - case type - when 'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256', - 'int8', 'int16', 'int32', 'int64', 'int128', 'int256' - value&.to_i - when 'address', 'string', /^bytes/ - value - when 'bool' - if value.is_a?(String) - value == 'true' - else - !value.nil? + response = Coinbase.call_api do + smart_contracts_api.read_contract( + network.normalized_id, + contract_address, + { + method: method, + args: (args || {}).to_json, + abi: abi&.to_json + }.compact + ) end - when 'array' - values ? values.map { |v| convert_solidity_value(v) } : [] - when 'tuple' - if values - result = {} - values.each do |v| - raise ArgumentError, 'Error: Tuple value without a name' unless v.respond_to?(:name) - - result[v.name] = convert_solidity_value(v) + + convert_solidity_value(response) + end + + def list + Coinbase::Pagination.enumerate( + lambda { |page| + smart_contracts_api.list_smart_contracts(page: page) + } + ) do |smart_contract| + new(smart_contract) + end + end + + # Normalizes an ABI from a String or Array of Hashes to an Array of Hashes. + # @param abi [String, Array] The ABI to normalize + # @return [Array] The normalized ABI + # @raise [ArgumentError] If the ABI is not a valid JSON string or Array + def normalize_abi(abi) + return abi if abi.is_a?(Array) + + raise ArgumentError, 'ABI must be an Array or a JSON string' unless abi.is_a?(String) + + JSON.parse(abi) + rescue JSON::ParserError + raise ArgumentError, 'Invalid ABI JSON' + end + + private + + # Converts a Solidity value to an appropriate Ruby type. + # + # @param solidity_value [Coinbase::Client::SolidityValue] The Solidity value to convert + # @return [Object] The converted Ruby value + # @raise [ArgumentError] If an unsupported Solidity type is encountered + # + # This method handles the following Solidity types: + # - Integers (uint8, uint16, uint32, uint64, uint128, uint256, int8, int16, int32, int64, int128, int256) + # - Address + # - String + # - Bytes (including fixed-size byte arrays) + # - Boolean + # - Array + # - Tuple (converted to a Hash) + # + # For complex types like arrays and tuples, the method recursively converts nested values. + def convert_solidity_value(solidity_value) + return nil if solidity_value.nil? + + type = solidity_value.type + value = solidity_value.value + values = solidity_value.values + + case type + when 'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256', + 'int8', 'int16', 'int32', 'int64', 'int128', 'int256' + value&.to_i + when 'address', 'string', /^bytes/ + value + when 'bool' + if value.is_a?(String) + value == 'true' + else + !value.nil? + end + when 'array' + values ? values.map { |v| convert_solidity_value(v) } : [] + when 'tuple' + if values + result = {} + values.each do |v| + raise ArgumentError, 'Error: Tuple value without a name' unless v.respond_to?(:name) + + result[v.name] = convert_solidity_value(v) + end + result + else + {} end - result else - {} + raise ArgumentError, "Unsupported Solidity type: #{type}" end - else - raise ArgumentError, "Unsupported Solidity type: #{type}" end - end - private_class_method :convert_solidity_value - def self.contract_events_api - Coinbase::Client::ContractEventsApi.new(Coinbase.configuration.api_client) - end - private_class_method :contract_events_api + def contract_events_api + Coinbase::Client::ContractEventsApi.new(Coinbase.configuration.api_client) + end - def self.smart_contracts_api - Coinbase::Client::SmartContractsApi.new(Coinbase.configuration.api_client) - end - private_class_method :smart_contracts_api - - def self.list_events_page( - network_id, - protocol_name, - contract_address, - contract_name, - event_name, - from_block_height, - to_block_height, - page - ) - contract_events_api.list_contract_events( - Coinbase.normalize_network(network_id), + def smart_contracts_api + Coinbase::Client::SmartContractsApi.new(Coinbase.configuration.api_client) + end + + def list_events_page( + network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, - { next_page: page } + page ) + contract_events_api.list_contract_events( + Coinbase.normalize_network(network_id), + protocol_name, + contract_address, + contract_name, + event_name, + from_block_height, + to_block_height, + { next_page: page } + ) + end end - private_class_method :list_events_page # Returns a new SmartContract object. # @param model [Coinbase::Client::SmartContract] The underlying SmartContract object @@ -282,8 +336,15 @@ def contract_address @model.contract_address end - # Returns the address of the deployer of the SmartContract. - # @return [String] The deployer address + # Returns the name of the SmartContract. + # @return [String] The contract name + def name + @model.contract_name + end + + # Returns the address of the deployer of the SmartContract, if deployed via CDP. + # Returns nil for externally registered contracts. + # @return [String, nil] The deployer address def deployer_address @model.deployer_address end @@ -294,7 +355,8 @@ def abi JSON.parse(@model.abi) end - # Returns the ID of the wallet that deployed the SmartContract. + # Returns the ID of the wallet that deployed the SmartContract, if deployed via CDP. + # Returns nil for externally registered contracts. # @return [String] The wallet ID def wallet_id @model.wallet_id @@ -306,22 +368,45 @@ def type @model.type end - # Returns the options of the SmartContract. - # @return [Coinbase::Client::SmartContractOptions] The SmartContract options + # Returns the options of the SmartContract, if deployed via CDP. + # Returns nil for externally registered contracts. + # @return [Coinbase::Client::SmartContractOptions, nil] The SmartContract options def options @model.options end - # Returns the transaction. - # @return [Coinbase::Transaction] The SmartContracy deployment transaction + # Returns whether the SmartContract is an externally registered contract or a CDP managed contract. + # @return [Boolean] Whether the SmartContract is external + def external? + @model.is_external + end + + # Returns the transaction, if deployed via CDP. + # @return [Coinbase::Transaction] The SmartContract deployment transaction def transaction - @transaction ||= Coinbase::Transaction.new(@model.transaction) + @transaction ||= @model.transaction.nil? ? nil : Coinbase::Transaction.new(@model.transaction) end - # Returns the status of the SmartContract. + # Returns the status of the SmartContract, if deployed via CDP. # @return [String] The status def status - transaction.status + transaction&.status + end + + def update(name: nil, abi: nil) + req = {} + req[:contract_name] = name unless name.nil? + req[:abi] = self.class.normalize_abi(abi).to_json unless abi.nil? + + @model = Coinbase.call_api do + smart_contracts_api.update_smart_contract( + network.normalized_id, + contract_address, + update_smart_contract_request: req + ) + end + + self end # Signs the SmartContract deployment transaction with the given key. @@ -329,8 +414,10 @@ def status # @param key [Eth::Key] The key to sign the SmartContract with # @return [SmartContract] The SmartContract object # @raise [RuntimeError] If the key is not an Eth::Key + # @raise [RuntimeError] If the SmartContract is external # @raise [Coinbase::AlreadySignedError] If the SmartContract has already been signed def sign(key) + raise ManageExternalContractError, 'sign' if external? raise unless key.is_a?(Eth::Key) transaction.sign(key) @@ -339,7 +426,9 @@ def sign(key) # Deploys the signed SmartContract to the blockchain. # @return [SmartContract] The SmartContract object # @raise [Coinbase::TransactionNotSignedError] If the SmartContract has not been signed + # @raise [RuntimeError] If the SmartContract is external def deploy! + raise ManageExternalContractError, 'deploy' if external? raise TransactionNotSignedError unless transaction.signed? @model = Coinbase.call_api do @@ -359,15 +448,13 @@ def deploy! # Reloads the Smart Contract model with the latest version from the server side. # @return [SmartContract] The most recent version of Smart Contract from the server def reload + raise ManageExternalContractError, 'reload' if external? + @model = Coinbase.call_api do - smart_contracts_api.get_smart_contract( - wallet_id, - deployer_address, - id - ) + smart_contracts_api.get_smart_contract(wallet_id, deployer_address, id) end - @transaction = Coinbase::Transaction.new(@model.transaction) + @transaction = Coinbase::Transaction.new(@model.transaction) if @model.transaction self end @@ -379,6 +466,8 @@ def reload # @return [SmartContract] The completed Smart Contract object # @raise [Timeout::Error] if the Contract Invocation takes longer than the given timeout def wait!(interval_seconds = 0.2, timeout_seconds = 20) + raise ManageExternalContractError, 'wait!' if external? + start_time = Time.now loop do @@ -387,8 +476,7 @@ def wait!(interval_seconds = 0.2, timeout_seconds = 20) return self if transaction.terminal_state? if Time.now - start_time > timeout_seconds - raise Timeout::Error, - 'SmartContract deployment timed out. Try waiting again.' + raise Timeout::Error, 'SmartContract deployment timed out. Try waiting again.' end self.sleep interval_seconds @@ -408,12 +496,16 @@ def inspect def to_s Coinbase.pretty_print_object( self.class, - network: network.id, - contract_address: contract_address, - deployer_address: deployer_address, - type: type, - status: status, - options: Coinbase.pretty_print_object('Options', **options) + **{ + network: network.id, + contract_address: contract_address, + type: type, + name: name, + # Fields only present for CDP managed contracts. + status: status, + deployer_address: deployer_address, + options: options.nil? ? nil : Coinbase.pretty_print_object('Options', **options) + }.compact ) end @@ -423,4 +515,5 @@ def smart_contracts_api @smart_contracts_api ||= Coinbase::Client::SmartContractsApi.new(Coinbase.configuration.api_client) end end + # rubocop:enable Metrics/ClassLength end diff --git a/spec/factories/smart_contract.rb b/spec/factories/smart_contract.rb index cdbed341..8421c632 100644 --- a/spec/factories/smart_contract.rb +++ b/spec/factories/smart_contract.rb @@ -13,6 +13,7 @@ base_uri { 'https://test.com' } end + is_external { false } deployer_address { key.address.to_s } wallet_id { SecureRandom.uuid } smart_contract_id { SecureRandom.uuid } @@ -36,6 +37,7 @@ end trait :token do + type { Coinbase::Client::SmartContractType::ERC20 } options do Coinbase::Client::TokenContractOptions.new( name: name, @@ -43,9 +45,11 @@ total_supply: BigDecimal(total_supply).to_i.to_s ) end + contract_name { name } end trait :nft do + type { Coinbase::Client::SmartContractType::ERC721 } options do Coinbase::Client::NFTContractOptions.new( name: name, @@ -53,9 +57,11 @@ base_uri: base_uri ) end + contract_name { name } end trait :multi_token do + type { Coinbase::Client::SmartContractType::ERC1155 } options do Coinbase::Client::MultiTokenContractOptions.new( uri: 'https://example.com/token/{id}.json' @@ -63,6 +69,15 @@ end end + trait :external do + is_external { true } + deployer_address { nil } + wallet_id { nil } + type { Coinbase::Client::SmartContractType::CUSTOM } + options { nil } + contract_name { 'External Contract' } + end + NETWORK_TRAITS.each do |network| trait network do network_id { Coinbase.normalize_network(network) } @@ -76,7 +91,9 @@ end after(:build) do |invocation, transients| - invocation.transaction = build(:transaction_model, transients.status, key: transients.key) + unless invocation.is_external + invocation.transaction = build(:transaction_model, transients.status, key: transients.key) + end end end @@ -107,6 +124,10 @@ type { :multi_token } end + trait :external do + type { :external } + end + TX_TRAITS.each do |status| trait status do status { status } diff --git a/spec/unit/coinbase/smart_contract_spec.rb b/spec/unit/coinbase/smart_contract_spec.rb index 49174a89..e4682267 100644 --- a/spec/unit/coinbase/smart_contract_spec.rb +++ b/spec/unit/coinbase/smart_contract_spec.rb @@ -1,9 +1,7 @@ # frozen_string_literal: true describe Coinbase::SmartContract do - subject(:smart_contract) do - described_class.new(model) - end + subject(:smart_contract) { described_class.new(model) } let(:network_id) { :base_sepolia } let(:network) { build(:network, network_id) } @@ -23,6 +21,7 @@ total_supply: total_supply ) end + let(:external_model) { build(:smart_contract_model, network_id, :external) } before do allow(Coinbase::Client::SmartContractsApi).to receive(:new).and_return(smart_contracts_api) @@ -95,13 +94,16 @@ end let(:nft_contract_model) do - build(:smart_contract_model, network_id, - type: Coinbase::Client::SmartContractType::ERC721, - options: Coinbase::Client::NFTContractOptions.new( - name: nft_name, - symbol: nft_symbol, - base_uri: base_uri - )) + build( + :smart_contract_model, + network_id, + type: Coinbase::Client::SmartContractType::ERC721, + options: Coinbase::Client::NFTContractOptions.new( + name: nft_name, + symbol: nft_symbol, + base_uri: base_uri + ) + ) end before do @@ -160,11 +162,14 @@ end let(:multi_token_contract_model) do - build(:smart_contract_model, network_id, - type: Coinbase::Client::SmartContractType::ERC1155, - options: Coinbase::Client::MultiTokenContractOptions.new( - uri: uri - )) + build( + :smart_contract_model, + network_id, + type: Coinbase::Client::SmartContractType::ERC1155, + options: Coinbase::Client::MultiTokenContractOptions.new( + uri: uri + ) + ) end before do @@ -194,6 +199,174 @@ end end + describe '.list' do + subject(:enumerator) { described_class.list } + + let(:api) { smart_contracts_api } + let(:fetch_params) { ->(page) { [{ page: page }] } } + let(:resource_list_klass) { Coinbase::Client::SmartContractList } + let(:item_klass) { described_class } + let(:item_initialize_args) { nil } + let(:create_model) do + ->(id) { Coinbase::Client::SmartContract.new(smart_contract_id: id, network_id: :base_sepolia) } + end + + it_behaves_like 'it is a paginated enumerator', :smart_contracts + end + + describe '.register' do + subject(:smart_contract) do + described_class.register( + network: network, + contract_address: contract_address, + name: contract_name, + abi: request_abi + ) + end + + let(:contract_name) { 'TestContract' } + let(:contract_address) { '0x1234567890123456789012345678901234567890' } + let(:abi) { [{ 'name' => 'testMethod', 'inputs' => [], 'outputs' => [] }] } + let(:request_abi) { abi } + let(:register_smart_contract_request) do + { + contract_name: contract_name, + abi: abi.to_json + } + end + + let(:external_model) do + build( + :smart_contract_model, + network_id, + :external, + abi: abi.to_json, + contract_address: contract_address, + contract_name: contract_name + ) + end + + before do + allow(smart_contracts_api) + .to receive(:register_smart_contract) + .with( + network.normalized_id, + contract_address, + register_smart_contract_request: register_smart_contract_request + ).and_return(external_model) + end + + it 'creates a new SmartContract' do + expect(smart_contract).to be_a(described_class) + end + + it 'sets the smart_contract properties' do + expect(smart_contract.id).to eq(external_model.smart_contract_id) + end + + it 'sets the ABI' do + expect(smart_contract.abi).to eq(abi) + end + + it 'calls register_smart_contract with correct parameters' do + smart_contract + expect(smart_contracts_api).to have_received(:register_smart_contract) + .with( + network.normalized_id, + contract_address, + register_smart_contract_request: register_smart_contract_request + ) + end + + context 'when the name is omitted' do + subject(:smart_contract) do + described_class.register( + network: network, + contract_address: contract_address, + abi: request_abi + ) + end + + let(:register_smart_contract_request) { { abi: abi.to_json } } + + it 'calls register_smart_contract without a name' do + smart_contract + + expect(smart_contracts_api) + .to have_received(:register_smart_contract) + .with( + network.normalized_id, + contract_address, + register_smart_contract_request: register_smart_contract_request + ) + end + end + + context 'when the ABI is passed as a JSON-encoded string' do + let(:request_abi) { abi.to_json } + + it 'calls register_smart_contract with the ABI as a JSON-encoded string' do + smart_contract + + expect(smart_contracts_api) + .to have_received(:register_smart_contract) + .with( + network.normalized_id, + contract_address, + register_smart_contract_request: register_smart_contract_request + ) + end + end + + context 'when the ABI is not a valid JSON-encoded string' do + let(:abi) { 'invalid' } + + it 'raises an error' do + expect { smart_contract }.to raise_error(ArgumentError) + end + end + + context 'when the provided network is a symbol' do + let(:network_id) { :ethereum_mainnet } + + it 'calls register_smart_contract with the normalized network ID' do + smart_contract + + expect(smart_contracts_api) + .to have_received(:register_smart_contract) + .with( + 'ethereum-mainnet', + contract_address, + register_smart_contract_request: register_smart_contract_request + ) + end + end + + context 'when the network is omitted' do + subject(:smart_contract) do + described_class.register( + contract_address: contract_address, + name: contract_name, + abi: abi + ) + end + + let(:network) { default_network } + + it 'calls register_smart_contract with the default network' do + smart_contract + + expect(smart_contracts_api) + .to have_received(:register_smart_contract) + .with( + default_network.normalized_id, + contract_address, + register_smart_contract_request: register_smart_contract_request + ) + end + end + end + describe '.read' do subject(:result) do described_class.read( @@ -696,6 +869,12 @@ def build_nested_solidity_value(hash) end end + describe '#name' do + it 'returns the contract name' do + expect(smart_contract.name).to eq(model.contract_name) + end + end + describe '#abi' do it 'returns the parsed contract ABI' do expect(smart_contract.abi).to eq(JSON.parse(model.abi)) @@ -706,12 +885,28 @@ def build_nested_solidity_value(hash) it 'returns the wallet ID' do expect(smart_contract.wallet_id).to eq(wallet_id) end + + context 'when the smart contract is external' do + subject(:smart_contract) { described_class.new(external_model) } + + it 'returns nil' do + expect(smart_contract.wallet_id).to be_nil + end + end end describe '#deployer_address' do it 'returns the deployer address' do expect(smart_contract.deployer_address).to eq(model.deployer_address) end + + context 'when the smart contract is external' do + subject(:smart_contract) { described_class.new(external_model) } + + it 'returns nil' do + expect(smart_contract.deployer_address).to be_nil + end + end end describe '#type' do @@ -724,6 +919,14 @@ def build_nested_solidity_value(hash) it 'returns the smart contract options' do expect(smart_contract.options).to eq(model.options) end + + context 'when the smart contract is external' do + subject(:smart_contract) { described_class.new(external_model) } + + it 'returns nil' do + expect(smart_contract.options).to be_nil + end + end end describe '#transaction' do @@ -734,6 +937,120 @@ def build_nested_solidity_value(hash) it 'sets the from_address_id' do expect(smart_contract.transaction.from_address_id).to eq(address_id) end + + context 'when the smart contract is external' do + subject(:smart_contract) { described_class.new(external_model) } + + it 'returns nil' do + expect(smart_contract.transaction).to be_nil + end + end + end + + describe '#update' do + subject(:updated_smart_contract) { smart_contract.update(**options) } + + let(:smart_contract) { described_class.new(external_model) } + let(:updated_abi) { [{ 'name' => 'testMethod', 'inputs' => [], 'outputs' => [] }] } + let(:updated_name) { 'Updated contract name' } + let(:request_abi) { updated_abi } + let(:options) { { name: updated_name, abi: request_abi } } + let(:update_smart_contract_request) { { contract_name: updated_name, abi: updated_abi.to_json } } + let(:external_model) { build(:smart_contract_model, network_id, :external) } + let(:updated_model) do + build( + :smart_contract_model, + network_id, + :external, + abi: updated_abi.to_json, + contract_address: external_model.contract_address, + contract_name: updated_name + ) + end + + before do + allow(smart_contracts_api) + .to receive(:update_smart_contract) + .with( + network.normalized_id, + external_model.contract_address, + update_smart_contract_request: update_smart_contract_request + ).and_return(updated_model) + + updated_smart_contract + end + + it 'returns the updated SmartContract' do + expect(updated_smart_contract).to be_a(described_class) + end + + it 'calls update_smart_contract with correct parameters' do + expect(smart_contracts_api) + .to have_received(:update_smart_contract) + .with( + network.normalized_id, + external_model.contract_address, + update_smart_contract_request: update_smart_contract_request + ) + end + + it 'returns the updated ABI' do + expect(updated_smart_contract.abi).to eq(updated_abi) + end + + it 'returns the updated name' do + expect(updated_smart_contract.name).to eq(updated_name) + end + + context 'when the ABI is passed as a JSON-encoded string' do + let(:request_abi) { updated_abi.to_json } + + it 'calls update_smart_contract with the ABI as a JSON-encoded string' do + updated_smart_contract + + expect(smart_contracts_api) + .to have_received(:update_smart_contract) + .with( + network.normalized_id, + external_model.contract_address, + update_smart_contract_request: update_smart_contract_request + ) + end + end + + context 'when ABI is omitted' do + let(:options) { { name: updated_name } } + let(:update_smart_contract_request) { { contract_name: updated_name } } + + it 'calls update_smart_contract without an ABI' do + updated_smart_contract + + expect(smart_contracts_api) + .to have_received(:update_smart_contract) + .with( + network.normalized_id, + external_model.contract_address, + update_smart_contract_request: update_smart_contract_request + ) + end + end + + context 'when name is omitted' do + let(:options) { { abi: updated_abi } } + let(:update_smart_contract_request) { { abi: updated_abi.to_json } } + + it 'calls update_smart_contract without a name' do + updated_smart_contract + + expect(smart_contracts_api) + .to have_received(:update_smart_contract) + .with( + network.normalized_id, + external_model.contract_address, + update_smart_contract_request: update_smart_contract_request + ) + end + end end describe '#sign' do @@ -763,6 +1080,16 @@ def build_nested_solidity_value(hash) expect { smart_contract.sign('invalid key') }.to raise_error(RuntimeError) end end + + context 'when the smart contract is external' do + subject(:smart_contract) { build(:smart_contract, :external) } + + let(:key) { Eth::Key.new } + + it 'raises an error' do + expect { smart_contract.sign(key) }.to raise_error(Coinbase::ManageExternalContractError) + end + end end describe '#deploy!' do @@ -824,6 +1151,14 @@ def build_nested_solidity_value(hash) expect { deployed_smart_contract }.to raise_error(Coinbase::TransactionNotSignedError) end end + + context 'when the smart contract is external' do + subject(:smart_contract) { build(:smart_contract, :external) } + + it 'raises an error' do + expect { smart_contract.deploy! }.to raise_error(Coinbase::ManageExternalContractError) + end + end end describe '#reload' do @@ -839,6 +1174,14 @@ def build_nested_solidity_value(hash) it 'updates the smart contract transaction' do expect(smart_contract.reload.transaction.status).to eq(Coinbase::Transaction::Status::COMPLETE) end + + context 'when the smart contract is external' do + subject(:smart_contract) { build(:smart_contract, :external) } + + it 'raises an error' do + expect { smart_contract.reload }.to raise_error(Coinbase::ManageExternalContractError) + end + end end describe '#wait!' do @@ -876,6 +1219,16 @@ def build_nested_solidity_value(hash) end.to raise_error(Timeout::Error, 'SmartContract deployment timed out. Try waiting again.') end end + + context 'when the smart contract is external' do + subject(:smart_contract) { build(:smart_contract, :external) } + + let(:updated_model) { nil } + + it 'raises an error' do + expect { smart_contract.wait! }.to raise_error(Coinbase::ManageExternalContractError) + end + end end describe '#inspect' do @@ -883,6 +1236,7 @@ def build_nested_solidity_value(hash) expect(smart_contract.inspect).to include( address_id, Coinbase.to_sym(network_id).to_s, + smart_contract.name, smart_contract.transaction.status.to_s, token_name, token_symbol, @@ -902,5 +1256,18 @@ def build_nested_solidity_value(hash) expect(smart_contract.inspect).to include('broadcast') end end + + context 'when the smart contract is external' do + subject(:smart_contract) { build(:smart_contract, :external) } + + it 'includes the external smart contract details' do + expect(smart_contract.inspect).to include( + smart_contract.contract_address, + Coinbase.to_sym(network_id).to_s, + smart_contract.name, + 'custom' + ) + end + end end end From 614f7a30bdde96b10eeb9cc6ac78a6128ed388fc Mon Sep 17 00:00:00 2001 From: Alexander Stone Date: Thu, 19 Dec 2024 13:48:12 -0800 Subject: [PATCH 4/4] chore: Prepare for release v0.13.0 (#224) ### What changed? Why? Update changelog and bump version #### Qualified Impact --- CHANGELOG.md | 11 ++++++----- lib/coinbase/version.rb | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae685bbd..6c7a1dee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased -* Add support for fetching address reputation. -* Add `network_id` to `WalletData` so that it is saved with the seed data and surfaced via the export function -* Add support for registering, updating, and listing smart contracts that are - deployed external to CDP. +## [0.13.0] - 2024-12-19 + +### Added +- Add support for fetching address reputation. +- Add `network_id` to `WalletData` so that it is saved with the seed data and surfaced via the export function +- Add support for registering, updating, and listing smart contracts that are deployed external to CDP. ## [0.12.0] - Skipped diff --git a/lib/coinbase/version.rb b/lib/coinbase/version.rb index 7c756c93..b9e72b0c 100644 --- a/lib/coinbase/version.rb +++ b/lib/coinbase/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Coinbase - VERSION = '0.11.0' + VERSION = '0.13.0' end