From 7e58bd6eef62e55abd8362eafeb374c4522471f4 Mon Sep 17 00:00:00 2001 From: Howard Xie Date: Thu, 19 Sep 2024 16:51:07 -0700 Subject: [PATCH 1/6] tx history scope --- lib/coinbase/client.rb | 1 + .../client/api/external_addresses_api.rb | 79 -------------- .../client/api/transaction_history_api.rb | 101 ++++++++++++++++++ lib/coinbase/client/models/feature.rb | 43 -------- .../client/models/network_identifier.rb | 3 +- 5 files changed, 104 insertions(+), 123 deletions(-) create mode 100644 lib/coinbase/client/api/transaction_history_api.rb delete mode 100644 lib/coinbase/client/models/feature.rb diff --git a/lib/coinbase/client.rb b/lib/coinbase/client.rb index ac1227ee..f75e87a3 100644 --- a/lib/coinbase/client.rb +++ b/lib/coinbase/client.rb @@ -123,6 +123,7 @@ Coinbase::Client.autoload :SmartContractsApi, 'coinbase/client/api/smart_contracts_api' Coinbase::Client.autoload :StakeApi, 'coinbase/client/api/stake_api' Coinbase::Client.autoload :TradesApi, 'coinbase/client/api/trades_api' +Coinbase::Client.autoload :TransactionHistoryApi, 'coinbase/client/api/transaction_history_api' Coinbase::Client.autoload :TransfersApi, 'coinbase/client/api/transfers_api' Coinbase::Client.autoload :UsersApi, 'coinbase/client/api/users_api' Coinbase::Client.autoload :ValidatorsApi, 'coinbase/client/api/validators_api' diff --git a/lib/coinbase/client/api/external_addresses_api.rb b/lib/coinbase/client/api/external_addresses_api.rb index 5a3ea522..888c5104 100644 --- a/lib/coinbase/client/api/external_addresses_api.rb +++ b/lib/coinbase/client/api/external_addresses_api.rb @@ -94,85 +94,6 @@ def get_external_address_balance_with_http_info(network_id, address_id, asset_id return data, status_code, headers end - # List transactions for an address. - # List all transactions that interact with the address. - # @param network_id [String] The ID of the blockchain network - # @param address_id [String] The ID of the address to fetch the transactions for. - # @param [Hash] opts the optional parameters - # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - # @option opts [String] :page A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. - # @return [AddressTransactionList] - def list_address_transactions(network_id, address_id, opts = {}) - data, _status_code, _headers = list_address_transactions_with_http_info(network_id, address_id, opts) - data - end - - # List transactions for an address. - # List all transactions that interact with the address. - # @param network_id [String] The ID of the blockchain network - # @param address_id [String] The ID of the address to fetch the transactions for. - # @param [Hash] opts the optional parameters - # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - # @option opts [String] :page A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. - # @return [Array<(AddressTransactionList, Integer, Hash)>] AddressTransactionList data, response status code and response headers - def list_address_transactions_with_http_info(network_id, address_id, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: ExternalAddressesApi.list_address_transactions ...' - 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.list_address_transactions" - 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.list_address_transactions" - end - if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'].to_s.length > 5000 - fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ExternalAddressesApi.list_address_transactions, the character length must be smaller than or equal to 5000.' - end - - # resource path - local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/transactions'.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] || {} - query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? - query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? - - # 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] || 'AddressTransactionList' - - # auth_names - auth_names = opts[:debug_auth_names] || [] - - new_options = opts.merge( - :operation => :"ExternalAddressesApi.list_address_transactions", - :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#list_address_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - # Get the balances of an external address # List all of the balances of an external address # @param network_id [String] The ID of the blockchain network diff --git a/lib/coinbase/client/api/transaction_history_api.rb b/lib/coinbase/client/api/transaction_history_api.rb new file mode 100644 index 00000000..296ed051 --- /dev/null +++ b/lib/coinbase/client/api/transaction_history_api.rb @@ -0,0 +1,101 @@ +=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.8.0 + +=end + +require 'cgi' + +module Coinbase::Client + class TransactionHistoryApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # List transactions for an address. + # List all transactions that interact with the address. + # @param network_id [String] The ID of the blockchain network + # @param address_id [String] The ID of the address to fetch the transactions for. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + # @option opts [String] :page A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + # @return [AddressTransactionList] + def list_address_transactions(network_id, address_id, opts = {}) + data, _status_code, _headers = list_address_transactions_with_http_info(network_id, address_id, opts) + data + end + + # List transactions for an address. + # List all transactions that interact with the address. + # @param network_id [String] The ID of the blockchain network + # @param address_id [String] The ID of the address to fetch the transactions for. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + # @option opts [String] :page A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + # @return [Array<(AddressTransactionList, Integer, Hash)>] AddressTransactionList data, response status code and response headers + def list_address_transactions_with_http_info(network_id, address_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TransactionHistoryApi.list_address_transactions ...' + 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 TransactionHistoryApi.list_address_transactions" + 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 TransactionHistoryApi.list_address_transactions" + end + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'].to_s.length > 5000 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling TransactionHistoryApi.list_address_transactions, the character length must be smaller than or equal to 5000.' + end + + # resource path + local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/transactions'.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] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + + # 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] || 'AddressTransactionList' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"TransactionHistoryApi.list_address_transactions", + :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: TransactionHistoryApi#list_address_transactions\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/feature.rb b/lib/coinbase/client/models/feature.rb deleted file mode 100644 index 35568b8c..00000000 --- a/lib/coinbase/client/models/feature.rb +++ /dev/null @@ -1,43 +0,0 @@ -=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 -Contact: yuga.cohler@coinbase.com -Generated by: https://openapi-generator.tech -Generator version: 7.7.0 - -=end - -require 'date' -require 'time' - -module Coinbase::Client - class Feature - TRANSFER = "transfer".freeze - TRADE = "trade".freeze - FAUCET = "faucet".freeze - SERVER_SIGNER = "server_signer".freeze - UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze - - def self.all_vars - @all_vars ||= [TRANSFER, TRADE, FAUCET, SERVER_SIGNER, UNKNOWN_DEFAULT_OPEN_API].freeze - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if Feature.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #Feature" - end - end -end diff --git a/lib/coinbase/client/models/network_identifier.rb b/lib/coinbase/client/models/network_identifier.rb index e7ed620b..3dc097b5 100644 --- a/lib/coinbase/client/models/network_identifier.rb +++ b/lib/coinbase/client/models/network_identifier.rb @@ -21,11 +21,12 @@ class NetworkIdentifier ETHEREUM_MAINNET = "ethereum-mainnet".freeze POLYGON_MAINNET = "polygon-mainnet".freeze SOLANA_DEVNET = "solana-devnet".freeze + SOLANA_MAINNET = "solana-mainnet".freeze ARBITRUM_MAINNET = "arbitrum-mainnet".freeze UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze def self.all_vars - @all_vars ||= [BASE_SEPOLIA, BASE_MAINNET, ETHEREUM_HOLESKY, ETHEREUM_MAINNET, POLYGON_MAINNET, SOLANA_DEVNET, ARBITRUM_MAINNET, UNKNOWN_DEFAULT_OPEN_API].freeze + @all_vars ||= [BASE_SEPOLIA, BASE_MAINNET, ETHEREUM_HOLESKY, ETHEREUM_MAINNET, POLYGON_MAINNET, SOLANA_DEVNET, SOLANA_MAINNET, ARBITRUM_MAINNET, UNKNOWN_DEFAULT_OPEN_API].freeze end # Builds the enum from string From f2782aa07be03193bf6811e3587d97a382e5ffba Mon Sep 17 00:00:00 2001 From: Howard Xie Date: Thu, 19 Sep 2024 16:59:45 -0700 Subject: [PATCH 2/6] Update address.rb --- lib/coinbase/address.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/coinbase/address.rb b/lib/coinbase/address.rb index b1084f1c..4e0d5a2a 100644 --- a/lib/coinbase/address.rb +++ b/lib/coinbase/address.rb @@ -252,6 +252,10 @@ def balance_history_api @balance_history_api ||= Coinbase::Client::BalanceHistoryApi.new(Coinbase.configuration.api_client) end + def transaction_history_api + @transaction_history_api ||= Coinbase::Client::TransactionHistoryApi.new(Coinbase.configuration.api_client) + end + def stake_api @stake_api ||= Coinbase::Client::StakeApi.new(Coinbase.configuration.api_client) end @@ -266,7 +270,7 @@ def list_page(asset_id, page) end def list_transaction_page(page) - addresses_api.list_address_transactions( + transaction_history_api.list_address_transactions( network.normalized_id, id, { limit: DEFAULT_TRANSACTION_PAGE_LIMIT, page: page } From 36ff430ec77481adab125b31b865a9c8680fb45b Mon Sep 17 00:00:00 2001 From: Howard Xie Date: Thu, 19 Sep 2024 17:02:34 -0700 Subject: [PATCH 3/6] Update address_transactions.rb --- spec/support/shared_examples/address_transactions.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/support/shared_examples/address_transactions.rb b/spec/support/shared_examples/address_transactions.rb index 8707274e..f2318c6f 100644 --- a/spec/support/shared_examples/address_transactions.rb +++ b/spec/support/shared_examples/address_transactions.rb @@ -2,6 +2,7 @@ shared_examples 'an address that supports transaction queries' do |_operation| let(:external_addresses_api) { instance_double(Coinbase::Client::ExternalAddressesApi) } + let(:transaction_history_api) { instance_double(Coinbase::Client::TransactionHistoryApi) } before do allow(Coinbase::Client::ExternalAddressesApi).to receive(:new).and_return(external_addresses_api) @@ -18,7 +19,7 @@ end before do - allow(external_addresses_api) + allow(transaction_history_api) .to receive(:list_address_transactions) .with(normalized_network_id, address_id, { limit: 10, page: nil }) .and_return(response) From 535bcd25487c7fe17ff3bfc57d71b2ee121062af Mon Sep 17 00:00:00 2001 From: Howard Xie Date: Thu, 19 Sep 2024 17:10:29 -0700 Subject: [PATCH 4/6] Update address_transactions.rb --- spec/support/shared_examples/address_transactions.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/support/shared_examples/address_transactions.rb b/spec/support/shared_examples/address_transactions.rb index f2318c6f..a475b7d4 100644 --- a/spec/support/shared_examples/address_transactions.rb +++ b/spec/support/shared_examples/address_transactions.rb @@ -6,6 +6,8 @@ before do allow(Coinbase::Client::ExternalAddressesApi).to receive(:new).and_return(external_addresses_api) + allow(Coinbase::Client::TransactionHistoryApi).to receive(:new).and_return(transaction_history_api) + end describe '#transactions' do From 6a55012e3a5d45843cd1088c88dc1d486e77cd2b Mon Sep 17 00:00:00 2001 From: Howard Xie Date: Thu, 19 Sep 2024 17:16:34 -0700 Subject: [PATCH 5/6] Update address_transactions.rb --- spec/support/shared_examples/address_transactions.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/support/shared_examples/address_transactions.rb b/spec/support/shared_examples/address_transactions.rb index a475b7d4..04417432 100644 --- a/spec/support/shared_examples/address_transactions.rb +++ b/spec/support/shared_examples/address_transactions.rb @@ -7,7 +7,6 @@ before do allow(Coinbase::Client::ExternalAddressesApi).to receive(:new).and_return(external_addresses_api) allow(Coinbase::Client::TransactionHistoryApi).to receive(:new).and_return(transaction_history_api) - end describe '#transactions' do From 4032b8aeedf48cc89618719cbf4ea60ea1b04c07 Mon Sep 17 00:00:00 2001 From: Howard Xie Date: Thu, 19 Sep 2024 17:20:24 -0700 Subject: [PATCH 6/6] Update address_transactions.rb --- spec/support/shared_examples/address_transactions.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/support/shared_examples/address_transactions.rb b/spec/support/shared_examples/address_transactions.rb index 04417432..351c5362 100644 --- a/spec/support/shared_examples/address_transactions.rb +++ b/spec/support/shared_examples/address_transactions.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true shared_examples 'an address that supports transaction queries' do |_operation| - let(:external_addresses_api) { instance_double(Coinbase::Client::ExternalAddressesApi) } let(:transaction_history_api) { instance_double(Coinbase::Client::TransactionHistoryApi) } before do - allow(Coinbase::Client::ExternalAddressesApi).to receive(:new).and_return(external_addresses_api) allow(Coinbase::Client::TransactionHistoryApi).to receive(:new).and_return(transaction_history_api) end @@ -37,7 +35,7 @@ address.transactions end - let(:api) { external_addresses_api } + let(:api) { transaction_history_api } let(:fetch_params) { ->(page) { [normalized_network_id, address_id, { limit: 10, page: page }] } } let(:resource_list_klass) { Coinbase::Client::AddressTransactionList } let(:item_klass) { Coinbase::Transaction }