Skip to content

Commit

Permalink
chore: Update OpenAPI spec client names
Browse files Browse the repository at this point in the history
This updates the `Wallet Stake` => `MPC Wallet Stake` and this moves
`Validators` -> `Stake` API to reflect changes to the OpenAPI spec.
  • Loading branch information
alex-stone committed Nov 13, 2024
1 parent 326b99c commit 1e59437
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/coinbase/staking_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def self.stake_api
private_class_method :stake_api

def self.wallet_stake_api
Coinbase::Client::WalletStakeApi.new(Coinbase.configuration.api_client)
Coinbase::Client::MPCWalletStakeApi.new(Coinbase.configuration.api_client)
end

private_class_method :wallet_stake_api
Expand Down Expand Up @@ -324,7 +324,7 @@ def stake_api
end

def wallet_stake_api
@wallet_stake_api ||= Coinbase::Client::WalletStakeApi.new(Coinbase.configuration.api_client)
@wallet_stake_api ||= Coinbase::Client::MPCWalletStakeApi.new(Coinbase.configuration.api_client)
end

def update_transactions(transactions)
Expand Down
17 changes: 7 additions & 10 deletions lib/coinbase/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ def self.fetch(network, asset_id, validator_id)
network = Coinbase::Network.from_id(network)

validator = Coinbase.call_api do
validators_api.get_validator(
network.normalized_id,
asset_id,
validator_id
)
stake_api.get_validator(network.normalized_id, asset_id, validator_id)
end

new(validator)
end

Expand All @@ -57,7 +54,7 @@ def status
# Returns a string representation of the Validator.
# @return [String] a string representation of the Validator
def to_s
"Coinbase::Validator{id: '#{validator_id}' status: '#{status}'}"
Coinbase.pretty_print_object(self, validator_id: validator_id, status: status)
end

# Same as to_s.
Expand All @@ -68,7 +65,7 @@ def inspect

def self.list_page(network, asset_id, status, page)
Coinbase.call_api do
validators_api.list_validators(
stake_api.list_validators(
network.normalized_id,
asset_id,
{
Expand All @@ -81,10 +78,10 @@ def self.list_page(network, asset_id, status, page)

private_class_method :list_page

def self.validators_api
Coinbase::Client::ValidatorsApi.new(Coinbase.configuration.api_client)
def self.stake_api
Coinbase::Client::StakeApi.new(Coinbase.configuration.api_client)
end

private_class_method :validators_api
private_class_method :stake_api
end
end
4 changes: 2 additions & 2 deletions spec/unit/coinbase/staking_operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
let(:hex_encoded_transaction) { '0xdeadbeef' }

let(:stake_api) { instance_double(Coinbase::Client::StakeApi) }
let(:wallet_stake_api) { instance_double(Coinbase::Client::WalletStakeApi) }
let(:wallet_stake_api) { instance_double(Coinbase::Client::MPCWalletStakeApi) }
let(:raw_tx) { instance_double(Eth::Tx::Eip1559) }

before do
allow(Coinbase::Client::StakeApi).to receive(:new).and_return(stake_api)
allow(Coinbase::Client::WalletStakeApi).to receive(:new).and_return(wallet_stake_api)
allow(Coinbase::Client::MPCWalletStakeApi).to receive(:new).and_return(wallet_stake_api)

allow(staking_operation_model).to receive(:transactions).and_return([transaction_model])
allow(transaction_model).to receive(:unsigned_payload).and_return('some_unsigned_payload')
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/coinbase/validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:network) { build(:network, network_id) }
let(:asset_id) { :asset_id }
let(:validator_id) { 'validator_id' }
let(:stake_api) { instance_double(Coinbase::Client::ValidatorsApi) }
let(:stake_api) { instance_double(Coinbase::Client::StakeApi) }
let(:validator_model) do
instance_double(
Coinbase::Client::Validator,
Expand All @@ -16,7 +16,7 @@
end

before do
allow(Coinbase::Client::ValidatorsApi).to receive(:new).and_return(stake_api)
allow(Coinbase::Client::StakeApi).to receive(:new).and_return(stake_api)
allow(stake_api).to receive(:get_validator).and_return(validator_model)
end

Expand Down

0 comments on commit 1e59437

Please sign in to comment.