Skip to content

Commit

Permalink
make format
Browse files Browse the repository at this point in the history
  • Loading branch information
John-peterson-coinbase committed May 6, 2024
1 parent 44febab commit e5de546
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
API_KEY_NAME: ${{ secrets.API_KEY_NAME }}
API_KEY_PRIVATE_KEY: ${{ secrets.API_KEY_PRIVATE_KEY }}
WALLET_DATA: ${{ secrets.WALLET_DATA }}
run: bundle exec rspec spec/e2e/production.rb
run: bundle exec rspec spec/e2e/production.rb
6 changes: 3 additions & 3 deletions lib/coinbase/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module Coinbase
ETH = Asset.new(network_id: :base_sepolia, asset_id: :eth, display_name: 'Ether')
USDC = Asset.new(network_id: :base_sepolia, asset_id: :usdc, display_name: 'USD Coin',
address_id: '0x036CbD53842c5426634e7929541eC2318f3dCF7e')
WETH = Asset.new(network_id: :base_sepolia, asset_id: :weth, display_name: 'Wrapped Ether',
address_id: '0x4200000000000000000000000000000000000006')
WETH = Asset.new(network_id: :base_sepolia, asset_id: :weth, display_name: 'Wrapped Ether',
address_id: '0x4200000000000000000000000000000000000006')
# The Base Sepolia Network.
BASE_SEPOLIA = Network.new(
network_id: :base_sepolia,
Expand Down Expand Up @@ -39,6 +39,6 @@ module Coinbase
gwei: true, # A medium denomination of Ether, typically used in gas prices.
wei: true, # The smallest denomination of Ether.
usdc: true, # USD Coin, a stablecoin pegged to the US Dollar.
weth: true, # Wrapped Ether, the ERC-20 compatible version of Ether.
weth: true # Wrapped Ether, the ERC-20 compatible version of Ether.
}.freeze
end
6 changes: 3 additions & 3 deletions lib/coinbase/transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def wait!(interval_seconds = 0.2, timeout_seconds = 10)
# Returns a String representation of the Transfer.
# @return [String] a String representation of the Transfer
def to_s
"Coinbase::Transfer{transfer_id: '#{transfer_id}', network_id: '#{network_id}', " +
"from_address_id: '#{from_address_id}', destination_address_id: '#{destination_address_id}', " +
"asset_id: '#{asset_id}', amount: '#{amount}', transaction_hash: '#{transaction_hash}', " +
"Coinbase::Transfer{transfer_id: '#{transfer_id}', network_id: '#{network_id}', " \
"from_address_id: '#{from_address_id}', destination_address_id: '#{destination_address_id}', " \
"asset_id: '#{asset_id}', amount: '#{amount}', transaction_hash: '#{transaction_hash}', " \
"transaction_link: '#{transaction_link}', status: '#{status}'}"
end

Expand Down
7 changes: 3 additions & 4 deletions lib/coinbase/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def save_wallet(wallet, encrypt: false)
iv = ''
if encrypt
shared_secret = store_encryption_key
cipher = OpenSSL::Cipher::AES256.new(:GCM).encrypt
cipher = OpenSSL::Cipher.new('aes-256-gcm').encrypt
cipher.key = OpenSSL::Digest.digest('SHA256', shared_secret)
iv = cipher.random_iv
cipher.iv = iv
Expand All @@ -96,7 +96,7 @@ def save_wallet(wallet, encrypt: false)
seed: seed_to_store,
encrypted: encrypt,
auth_tag: auth_tag,
iv: iv,
iv: iv
}

File.open(Coinbase.configuration.backup_file_path, 'w') do |file|
Expand All @@ -121,7 +121,7 @@ def load_wallets
raise ArgumentError, 'Malformed encrypted seed data' if seed_data['iv'] == '' ||
seed_data['auth_tag'] == ''

cipher = OpenSSL::Cipher::AES256.new(:GCM).decrypt
cipher = OpenSSL::Cipher.new('aes-256-gcm').decrypt
cipher.key = OpenSSL::Digest.digest('SHA256', shared_secret)
iv = [seed_data['iv']].pack('H*')
cipher.iv = iv
Expand Down Expand Up @@ -176,6 +176,5 @@ def store_encryption_key
public_key = pk.public_key # use own public key to generate the shared secret.
pk.dh_compute_key(public_key)
end

end
end
4 changes: 2 additions & 2 deletions lib/coinbase/wallet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def export
# Returns a String representation of the Wallet.
# @return [String] a String representation of the Wallet
def to_s
"Coinbase::Wallet{wallet_id: '#{wallet_id}', network_id: '#{network_id}', " +
"default_address: '#{default_address.address_id}'}"
"Coinbase::Wallet{wallet_id: '#{wallet_id}', network_id: '#{network_id}', " \
"default_address: '#{default_address.address_id}'}"
end

# Same as to_s.
Expand Down
24 changes: 12 additions & 12 deletions spec/unit/coinbase/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@
})
end
let(:initial_seed_data) { JSON.pretty_generate({}) }
let(:expected_seed_data) {
let(:expected_seed_data) do
{
seed_wallet.wallet_id => {
seed: seed,
encrypted: false
}
}
}
end

before do
allow(Coinbase::Client::AddressesApi).to receive(:new).and_return(addresses_api)
Expand Down Expand Up @@ -250,28 +250,28 @@
let(:address_list_model) do
Coinbase::Client::AddressList.new({ 'data' => [address_model], 'total_count' => 1 })
end
let(:initial_seed_data) {
let(:initial_seed_data) do
{
wallet_id => {
seed: seed,
encrypted: false
}
}
}
let(:malformed_seed_data) {
end
let(:malformed_seed_data) do
{
wallet_id => 'test'
}
}
let(:seed_data_without_seed) {
end
let(:seed_data_without_seed) do
{
wallet_id => {
seed: '',
encrypted: false
}
}
}
let(:seed_data_without_iv) {
end
let(:seed_data_without_iv) do
{
wallet_id => {
seed: seed,
Expand All @@ -280,8 +280,8 @@
auth_tag: '0x111'
}
}
}
let(:seed_data_without_auth_tag) {
end
let(:seed_data_without_auth_tag) do
{
wallet_id => {
seed: seed,
Expand All @@ -290,7 +290,7 @@
auth_tag: ''
}
}
}
end

before do
File.open(Coinbase.configuration.backup_file_path, 'w') do |file|
Expand Down

0 comments on commit e5de546

Please sign in to comment.