diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 6f9e49bd..56f8f641 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -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 \ No newline at end of file + run: bundle exec rspec spec/e2e/production.rb diff --git a/lib/coinbase/constants.rb b/lib/coinbase/constants.rb index a8cd11ec..07b32d91 100644 --- a/lib/coinbase/constants.rb +++ b/lib/coinbase/constants.rb @@ -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, @@ -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 diff --git a/lib/coinbase/transfer.rb b/lib/coinbase/transfer.rb index 69ae6158..da76dd53 100644 --- a/lib/coinbase/transfer.rb +++ b/lib/coinbase/transfer.rb @@ -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 diff --git a/lib/coinbase/user.rb b/lib/coinbase/user.rb index a519075c..e9095201 100644 --- a/lib/coinbase/user.rb +++ b/lib/coinbase/user.rb @@ -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 @@ -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| @@ -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 @@ -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 diff --git a/lib/coinbase/wallet.rb b/lib/coinbase/wallet.rb index 76af2cae..f44ae34f 100644 --- a/lib/coinbase/wallet.rb +++ b/lib/coinbase/wallet.rb @@ -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. diff --git a/spec/unit/coinbase/user_spec.rb b/spec/unit/coinbase/user_spec.rb index 0ee9fc86..9197ec90 100644 --- a/spec/unit/coinbase/user_spec.rb +++ b/spec/unit/coinbase/user_spec.rb @@ -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) @@ -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, @@ -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, @@ -290,7 +290,7 @@ auth_tag: '' } } - } + end before do File.open(Coinbase.configuration.backup_file_path, 'w') do |file|