-171
-172
-173
-174
+184
+185
+186
+187
- # File 'lib/coinbase/wallet.rb', line 171
+ # File 'lib/coinbase/wallet.rb', line 184
def initialize(wallet_id:, seed:)
@wallet_id = wallet_id
@@ -389,12 +389,12 @@
-166
-167
-168
+179
+180
+181
|
- # File 'lib/coinbase/wallet.rb', line 166
+ # File 'lib/coinbase/wallet.rb', line 179
def seed
@seed
@@ -432,12 +432,12 @@
-166
-167
-168
+179
+180
+181
|
- # File 'lib/coinbase/wallet.rb', line 166
+ # File 'lib/coinbase/wallet.rb', line 179
def wallet_id
@wallet_id
@@ -518,12 +518,12 @@
-185
-186
-187
+198
+199
+200
|
- # File 'lib/coinbase/wallet.rb', line 185
+ # File 'lib/coinbase/wallet.rb', line 198
def self.from_hash(data)
Data.new(wallet_id: data['wallet_id'], seed: data['seed'])
@@ -583,12 +583,12 @@
-178
-179
-180
+191
+192
+193
|
- # File 'lib/coinbase/wallet.rb', line 178
+ # File 'lib/coinbase/wallet.rb', line 191
def to_hash
{ wallet_id: wallet_id, seed: seed }
diff --git a/docs/class_list.html b/docs/class_list.html
index 32f27f47..4075ce63 100644
--- a/docs/class_list.html
+++ b/docs/class_list.html
@@ -43,7 +43,7 @@
-ApiError < StandardError Coinbase::Client Asset < Object Coinbase::Client Error < Object Coinbase::Client User < Object Coinbase::Client Wallet < Object Coinbase::Client
Data < Object Coinbase::Wallet
+ApiError < StandardError Coinbase::Client Asset < Object Coinbase::Client Error < Object Coinbase::Client User < Object Coinbase::Client Wallet < Object Coinbase::Client
Data < Object Coinbase::Wallet
diff --git a/docs/file.README.html b/docs/file.README.html
index 7c307d7d..757359fe 100644
--- a/docs/file.README.html
+++ b/docs/file.README.html
@@ -60,7 +60,7 @@
Coinbase Ruby SDK
- The Coinbase Ruby SDK enables the simple integration of crypto into your app. By calling Coinbase’s Platform APIs, the SDK allows you to provision crypto wallets, send crypto into/out of those wallets, track wallet balances, and trade crypto from one asset into another.
+ The Coinbase Ruby SDK enables the simple integration of crypto into your app. By calling Coinbase's Platform APIs, the SDK allows you to provision crypto wallets, send crypto into/out of those wallets, track wallet balances, and trade crypto from one asset into another.
The SDK currently supports Customer-custodied Wallets on the Base Sepolia test network.
@@ -122,7 +122,7 @@ Usage
Initialization
- To start, create a CDP API Key. Then, initialize the Platform SDK by passing your API Key name and API Key’s private key via the configure method:
+ To start, create a CDP API Key. Then, initialize the Platform SDK by passing your API Key name and API Key's private key via the configure method:
api_key_name = 'Copy your API Key name here.'
api_key_private_key = 'Copy your API Key\'s private key here.'
@@ -133,6 +133,11 @@ Initialization
end
+ Another way to initialize the SDK is by sourcing the API key from the json file that contains your API key, downloaded from CDP portal.
+
+ Coinbase.configure_from_json('~/Downloads/coinbase_cloud_api_key.json')
+
+
This will allow you to authenticate with the Platform APIs and get access to the default_user .
u = Coinbase.default_user
@@ -153,7 +158,14 @@ Wallets, Addresses, and Tra
a.to_s
- Wallets do not have funds on them to start. In order to fund the Address, you will need to send funds to the Wallet you generated above. If you don’t have testnet funds, get funds from a faucet.
+ Wallets do not have funds on them to start. In order to fund the Address, you will need to send funds to the Wallet you generated above. If you don't have testnet funds, get funds from a faucet.
+
+ For development purposes, we provide a faucet method to fund your address with ETH on Base Sepolia testnet. We allow one faucet claim per address in a 24 hour window.
+
+ faucet_tx = a.faucet
+faucet_tx.transaction_hash
+
store(data)
- For convenience during testing, we provide a save_wallet method that stores the Wallet data in your local file system. This is an insecure method of storing wallet seeds and should only be used for development purposes.
+ For convenience during testing, we provide a save_wallet method that stores the Wallet data in your local file system. This is an insecure method of storing wallet seeds and should only be used for development purposes. ruby u.save_wallet(w3)
- u.save_wallet(w3)
-
-
- To encrypt the saved data, set encrypt to true.
+ To encrypt the saved data, set encrypt to true. Note that your CDP API key also serves as the encryption key for the data persisted locally. To re-instantiate wallets with encrypted data, ensure that your SDK is configured with the same API key when invoking save_wallet and load_wallets .
- u.save_wallet(w3, true)
+u.save_wallet(w3, encrypt: true)
The below code demonstrates how to re-instantiate a Wallet from the data export.
@@ -195,13 +204,7 @@ Re-Instantiating Wallets
w4 = u.import_wallet(data)
- To import wallets that were persisted to your local file system using save_wallet , use the below code.
-
- wallets = u.load_wallets
-w5 = wallets[w3.wallet_id]
-
+ To import wallets that were persisted to your local file system using save_wallet , use the below code. ruby # The Wallet can be re-instantiated using the exported data. # w5 will be equivalent to w3. wallets = u.load_wallets w5 = wallets[w3.wallet_id]
Development
diff --git a/docs/index.html b/docs/index.html
index 33c13439..21e1615f 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -60,7 +60,7 @@
Coinbase Ruby SDK
- The Coinbase Ruby SDK enables the simple integration of crypto into your app. By calling Coinbase’s Platform APIs, the SDK allows you to provision crypto wallets, send crypto into/out of those wallets, track wallet balances, and trade crypto from one asset into another.
+ The Coinbase Ruby SDK enables the simple integration of crypto into your app. By calling Coinbase's Platform APIs, the SDK allows you to provision crypto wallets, send crypto into/out of those wallets, track wallet balances, and trade crypto from one asset into another.
The SDK currently supports Customer-custodied Wallets on the Base Sepolia test network.
@@ -122,7 +122,7 @@ Usage
Initialization
- To start, create a CDP API Key. Then, initialize the Platform SDK by passing your API Key name and API Key’s private key via the configure method:
+ To start, create a CDP API Key. Then, initialize the Platform SDK by passing your API Key name and API Key's private key via the configure method:
api_key_name = 'Copy your API Key name here.'
api_key_private_key = 'Copy your API Key\'s private key here.'
@@ -133,6 +133,11 @@ Initialization
end
+ Another way to initialize the SDK is by sourcing the API key from the json file that contains your API key, downloaded from CDP portal.
+
+ Coinbase.configure_from_json('~/Downloads/coinbase_cloud_api_key.json')
+
+
This will allow you to authenticate with the Platform APIs and get access to the default_user .
u = Coinbase.default_user
@@ -153,7 +158,14 @@ Wallets, Addresses, and Tra
a.to_s
- Wallets do not have funds on them to start. In order to fund the Address, you will need to send funds to the Wallet you generated above. If you don’t have testnet funds, get funds from a faucet.
+ Wallets do not have funds on them to start. In order to fund the Address, you will need to send funds to the Wallet you generated above. If you don't have testnet funds, get funds from a faucet.
+
+ For development purposes, we provide a faucet method to fund your address with ETH on Base Sepolia testnet. We allow one faucet claim per address in a 24 hour window.
+
+ faucet_tx = a.faucet
+faucet_tx.transaction_hash
+
store(data)
- For convenience during testing, we provide a save_wallet method that stores the Wallet data in your local file system. This is an insecure method of storing wallet seeds and should only be used for development purposes.
+ For convenience during testing, we provide a save_wallet method that stores the Wallet data in your local file system. This is an insecure method of storing wallet seeds and should only be used for development purposes. ruby u.save_wallet(w3)
- u.save_wallet(w3)
-
-
- To encrypt the saved data, set encrypt to true.
+ To encrypt the saved data, set encrypt to true. Note that your CDP API key also serves as the encryption key for the data persisted locally. To re-instantiate wallets with encrypted data, ensure that your SDK is configured with the same API key when invoking save_wallet and load_wallets .
- u.save_wallet(w3, true)
+u.save_wallet(w3, encrypt: true)
The below code demonstrates how to re-instantiate a Wallet from the data export.
@@ -195,13 +204,7 @@ Re-Instantiating Wallets
w4 = u.import_wallet(data)
- To import wallets that were persisted to your local file system using save_wallet , use the below code.
-
- wallets = u.load_wallets
-w5 = wallets[w3.wallet_id]
-
+ To import wallets that were persisted to your local file system using save_wallet , use the below code. ruby # The Wallet can be re-instantiated using the exported data. # w5 will be equivalent to w3. wallets = u.load_wallets w5 = wallets[w3.wallet_id]
Development
diff --git a/docs/method_list.html b/docs/method_list.html
index 016d111c..3dbc1527 100644
--- a/docs/method_list.html
+++ b/docs/method_list.html
@@ -46,192 +46,192 @@
- #==
- Coinbase::Client::BroadcastTransferRequest
+ #==
+ Coinbase::Client::Transfer
- #==
- Coinbase::Client::Balance
+ #==
+ Coinbase::Client::CreateTransferRequest
- #==
- Coinbase::Client::FaucetTransaction
+ #==
+ Coinbase::Client::User
- #==
- Coinbase::Client::Transfer
+ #==
+ Coinbase::Client::TransferList
- #==
- Coinbase::Client::User
+ #==
+ Coinbase::Client::Asset
- #==
- Coinbase::Client::Address
+ #==
+ Coinbase::Client::BroadcastTransferRequest
- #==
- Coinbase::Client::Wallet
+ #==
+ Coinbase::Client::CreateWalletRequest
- #==
- Coinbase::Client::CreateTransferRequest
+ #==
+ Coinbase::Client::WalletList
- #==
- Coinbase::Client::TransferList
+ #==
+ Coinbase::Client::AddressList
- #==
- Coinbase::Client::AddressBalanceList
+ #==
+ Coinbase::Client::Balance
- #==
- Coinbase::Client::CreateAddressRequest
+ #==
+ Coinbase::Client::FaucetTransaction
- #==
- Coinbase::Client::CreateWalletRequest
+ #==
+ Coinbase::Client::Address
- #==
- Coinbase::Client::AddressList
+ #==
+ Coinbase::Client::Wallet
- #==
- Coinbase::Client::Error
+ #==
+ Coinbase::Client::CreateAddressRequest
- #==
- Coinbase::Client::Asset
+ #==
+ Coinbase::Client::AddressBalanceList
- #==
- Coinbase::Client::WalletList
+ #==
+ Coinbase::Client::Error
- _deserialize
- Coinbase::Client::TransferList
+ #[]
+ Coinbase::BalanceMap
- _deserialize
- Coinbase::Client::AddressBalanceList
+ #[]=
+ Coinbase::BalanceMap
@@ -246,136 +246,136 @@
- #_to_hash
- Coinbase::Client::CreateAddressRequest
+ #_to_hash
+ Coinbase::Client::FaucetTransaction
- #_to_hash
- Coinbase::Client::AddressList
+ #_to_hash
+ Coinbase::Client::CreateAddressRequest
- #_to_hash
- Coinbase::Client::BroadcastTransferRequest
+ #_to_hash
+ Coinbase::Client::Wallet
@@ -390,32 +390,32 @@
- #_to_hash
- Coinbase::Client::CreateTransferRequest
+ #_to_hash
+ Coinbase::Client::Address
- #_to_hash
- Coinbase::Client::FaucetTransaction
+ #_to_hash
+ Coinbase::Client::CreateTransferRequest
- #_to_hash
- Coinbase::Client::Transfer
+ #_to_hash
+ Coinbase::Client::BroadcastTransferRequest
@@ -430,40 +430,40 @@
@@ -478,64 +478,64 @@
@@ -549,6 +549,14 @@
+
+
+
+
+
acceptable_attributes
Coinbase::Client::Wallet
@@ -556,6 +564,14 @@
+
+
+
+
+
#access_token
@@ -590,16 +606,16 @@
@@ -630,56 +646,56 @@
- #amount
- Coinbase::Client::Transfer
+ #amount
+ Coinbase::Client::Balance
@@ -766,40 +782,40 @@
- #asset_id
- Coinbase::Client::Asset
+ #asset_id
+ Coinbase::Client::CreateTransferRequest
- #asset_id
- Coinbase::Client::CreateTransferRequest
+ #asset_id
+ Coinbase::Client::Asset
@@ -814,128 +830,128 @@
@@ -1046,80 +1062,80 @@
@@ -1134,32 +1150,32 @@
@@ -1254,16 +1270,16 @@
- #config
- Coinbase::Client::ApiClient
+ config
+ Coinbase::Middleware
- config
- Coinbase::Middleware
+ #config
+ Coinbase::Client::ApiClient
@@ -1286,16 +1302,16 @@
@@ -1438,8 +1454,8 @@
- #data
- Coinbase::Client::TransferList
+ #data
+ Coinbase::Client::AddressBalanceList
@@ -1454,8 +1470,8 @@
- #data
- Coinbase::Client::AddressBalanceList
+ #data
+ Coinbase::Client::TransferList
@@ -1518,16 +1534,16 @@
@@ -1566,16 +1582,16 @@
@@ -1614,112 +1630,112 @@
- #eql?
- Coinbase::Client::Address
+ #eql?
+ Coinbase::Client::Transfer
- #eql?
- Coinbase::Client::User
+ #eql?
+ Coinbase::Client::Address
- #eql?
- Coinbase::Client::Asset
+ #eql?
+ Coinbase::Client::Wallet
- #eql?
- Coinbase::Client::Error
+ #eql?
+ Coinbase::Client::Balance
- #eql?
- Coinbase::Client::Wallet
+ #eql?
+ Coinbase::Client::AddressBalanceList
- #eql?
- Coinbase::Client::Balance
+ #eql?
+ Coinbase::Client::AddressList
- #eql?
- Coinbase::Client::Transfer
+ #eql?
+ Coinbase::Client::Error
- #eql?
- Coinbase::Client::WalletList
+ #eql?
+ Coinbase::Client::CreateWalletRequest
- #eql?
- Coinbase::Client::AddressList
+ #eql?
+ Coinbase::Client::BroadcastTransferRequest
- #eql?
- Coinbase::Client::TransferList
+ #eql?
+ Coinbase::Client::WalletList
- #eql?
- Coinbase::Client::FaucetTransaction
+ #eql?
+ Coinbase::Client::User
- #eql?
- Coinbase::Client::AddressBalanceList
+ #eql?
+ Coinbase::Client::FaucetTransaction
- #eql?
- Coinbase::Client::CreateWalletRequest
+ #eql?
+ Coinbase::Client::CreateAddressRequest
- #eql?
- Coinbase::Client::CreateAddressRequest
+ #eql?
+ Coinbase::Client::Asset
@@ -1734,8 +1750,8 @@
- #eql?
- Coinbase::Client::BroadcastTransferRequest
+ #eql?
+ Coinbase::Client::TransferList
@@ -1798,16 +1814,16 @@
@@ -1846,16 +1862,16 @@
@@ -1932,6 +1948,22 @@
+
+
+ #has_more
+ Coinbase::Client::TransferList
+
+
+
+
+
+
+
+
+
#has_more
@@ -1942,48 +1974,48 @@
- #has_more
- Coinbase::Client::TransferList
+ #hash
+ Coinbase::Client::WalletList
- #has_more
- Coinbase::Client::WalletList
+ #hash
+ Coinbase::Client::CreateWalletRequest
- #hash
- Coinbase::Client::Address
+ #hash
+ Coinbase::Client::AddressBalanceList
- #hash
- Coinbase::Client::TransferList
+ #hash
+ Coinbase::Client::Error
- #hash
- Coinbase::Client::WalletList
+ #hash
+ Coinbase::Client::Address
- #hash
- Coinbase::Client::Balance
+ #hash
+ Coinbase::Client::Wallet
@@ -1998,24 +2030,40 @@
- #hash
- Coinbase::Client::Error
+ #hash
+ Coinbase::Client::TransferList
- #hash
- Coinbase::Client::CreateWalletRequest
+ #hash
+ Coinbase::Client::Asset
- #hash
- Coinbase::Client::Wallet
+ #hash
+ Coinbase::Client::CreateTransferRequest
+
+
+
+
+
+
+ #hash
+ Coinbase::Client::BroadcastTransferRequest
+
+
+
+
+
+
+ #hash
+ Coinbase::Client::CreateAddressRequest
@@ -2030,400 +2078,416 @@
- #hash
- Coinbase::Client::BroadcastTransferRequest
+ #hash
+ Coinbase::Client::User
+
+
+
+
+
+
+ #hash
+ Coinbase::Client::Balance
+
+
+
+
+
+
+ #hash
+ Coinbase::Client::Transfer
- #hash
- Coinbase::Client::Asset
+ #host
+ Coinbase::Client::Configuration
- #hash
- Coinbase::Client::CreateAddressRequest
+ #http_code
+ Coinbase::APIError
- #hash
- Coinbase::Client::AddressBalanceList
+ #id
+ Coinbase::Client::Wallet
- #hash
- Coinbase::Client::Transfer
+ #id
+ Coinbase::Client::User
- #hash
- Coinbase::Client::CreateTransferRequest
+ #initialize
+ Coinbase::Client::CreateWalletRequest
- #host
- Coinbase::Client::Configuration
+ #initialize
+ Coinbase::Configuration
- #initialize
- Coinbase::Client::Transfer::EnumAttributeValidator
+ #initialize
+ Coinbase::Client::BroadcastTransferRequest
@@ -2510,16 +2574,16 @@
@@ -2534,96 +2598,96 @@
@@ -2742,40 +2806,40 @@
@@ -2830,16 +2894,16 @@
@@ -2862,16 +2926,16 @@
@@ -2886,136 +2950,136 @@
@@ -3030,88 +3094,88 @@
@@ -3150,16 +3214,16 @@
@@ -3326,24 +3390,24 @@
@@ -3398,16 +3462,16 @@
@@ -3438,64 +3502,64 @@
- #to_body
- Coinbase::Client::CreateWalletRequest
+ #to_body
+ Coinbase::Client::Asset
- #to_body
- Coinbase::Client::AddressList
+ #to_body
+ Coinbase::Client::Wallet
- #to_body
- Coinbase::Client::AddressBalanceList
+ #to_body
+ Coinbase::Client::Transfer
- #to_body
- Coinbase::Client::BroadcastTransferRequest
+ #to_body
+ Coinbase::Client::Error
- #to_body
- Coinbase::Client::Transfer
+ #to_body
+ Coinbase::Client::TransferList
@@ -3510,8 +3574,24 @@
- #to_body
- Coinbase::Client::CreateTransferRequest
+ #to_body
+ Coinbase::Client::AddressBalanceList
+
+
+
+
+
+
+ #to_body
+ Coinbase::Client::CreateWalletRequest
+
+
+
+
+
+
+ #to_body
+ Coinbase::Client::BroadcastTransferRequest
@@ -3526,16 +3606,16 @@
- #to_body
- Coinbase::Client::Wallet
+ #to_body
+ Coinbase::Client::CreateTransferRequest
- #to_body
- Coinbase::Client::TransferList
+ #to_body
+ Coinbase::Client::Address
@@ -3550,160 +3630,176 @@
- #to_body
- Coinbase::Client::Address
+ #to_hash
+ Coinbase::Client::TransferList
- #to_body
- Coinbase::Client::User
+ #to_hash
+ Coinbase::Client::CreateAddressRequest
- #to_hash
- Coinbase::Client::BroadcastTransferRequest
+ #to_hash
+ Coinbase::Client::AddressList
+
+
+
+
+
+
+ #to_hash
+ Coinbase::Client::FaucetTransaction
+
+
+
+
+
+
- #to_hash
- Coinbase::Client::AddressList
+ #to_hash
+ Coinbase::Client::AddressBalanceList
- #to_hash
- Coinbase::Client::FaucetTransaction
+ #to_hash
+ Coinbase::Client::Wallet
- #to_hash
- Coinbase::Wallet::Data
+ #to_hash
+ Coinbase::Client::CreateTransferRequest
- #to_hash
- Coinbase::Client::AddressBalanceList
+ #to_hash
+ Coinbase::Client::CreateWalletRequest
- #to_hash
- Coinbase::Client::CreateWalletRequest
+ #to_hash
+ Coinbase::Client::Error
- #to_hash
- Coinbase::Client::CreateTransferRequest
+ #to_hash
+ Coinbase::Client::BroadcastTransferRequest
- #to_hash
- Coinbase::Client::CreateAddressRequest
+ #to_hash
+ Coinbase::Client::WalletList
- #to_hash
- Coinbase::Client::Address
+ #to_s
+ Coinbase::Client::Asset
- #to_hash
- Coinbase::Client::Error
+ #to_s
+ Coinbase::Client::Balance
- #to_s
- Coinbase::Client::FaucetTransaction
+ #to_s
+ Coinbase::Client::TransferList
@@ -3718,80 +3814,80 @@
- #to_s
- Coinbase::Client::CreateWalletRequest
+ #to_s
+ Coinbase::Client::ApiError
- #to_s
- Coinbase::Address
+ #to_s
+ Coinbase::Client::User
- #to_s
- Coinbase::Client::User
+ #to_s
+ Coinbase::BalanceMap
- #to_s
- Coinbase::BalanceMap
+ #to_s
+ Coinbase::Client::FaucetTransaction
- #to_s
- Coinbase::Client::CreateTransferRequest
+ #to_s
+ Coinbase::Transfer
- #to_s
- Coinbase::Client::Balance
+ #to_s
+ Coinbase::Client::AddressBalanceList
- #to_s
- Coinbase::Client::Wallet
+ #to_s
+ Coinbase::Client::Address
- #to_s
- Coinbase::Client::Asset
+ #to_s
+ Coinbase::FaucetTransaction
- #to_s
- Coinbase::APIError
+ #to_s
+ Coinbase::Client::Wallet
- #to_s
- Coinbase::Client::CreateAddressRequest
+ #to_s
+ Coinbase::User
@@ -3806,56 +3902,56 @@
- #to_s
- Coinbase::Client::Error
+ #to_s
+ Coinbase::Client::CreateWalletRequest
- #to_s
- Coinbase::Client::TransferList
+ #to_s
+ Coinbase::Client::CreateTransferRequest
- #to_s
- Coinbase::Client::AddressBalanceList
+ #to_s
+ Coinbase::APIError
- #to_s
- Coinbase::Client::Transfer
+ #to_s
+ Coinbase::Client::WalletList
- #to_s
- Coinbase::Client::Address
+ #to_s
+ Coinbase::Client::Transfer
- #to_s
- Coinbase::Client::ApiError
+ #to_s
+ Coinbase::Client::Error
- #to_s
- Coinbase::Client::WalletList
+ #to_s
+ Coinbase::Client::CreateAddressRequest
@@ -3870,32 +3966,32 @@
@@ -3910,24 +4006,24 @@
@@ -3942,16 +4038,16 @@
@@ -4030,120 +4126,120 @@
- #valid?
- Coinbase::Client::CreateTransferRequest
+ #valid?
+ Coinbase::Client::AddressList
- #valid?
- Coinbase::Client::Error
+ #valid?
+ Coinbase::Client::FaucetTransaction
- #valid?
- Coinbase::Client::Wallet
+ #valid?
+ Coinbase::Client::BroadcastTransferRequest
- #valid?
- Coinbase::Client::Transfer::EnumAttributeValidator
+ #valid?
+ Coinbase::Client::Error
- #valid?
- Coinbase::Client::Transfer
+ #valid?
+ Coinbase::Client::CreateTransferRequest
- #valid?
- Coinbase::Client::BroadcastTransferRequest
+ #valid?
+ Coinbase::Client::Transfer
- #valid?
- Coinbase::Client::AddressBalanceList
+ #valid?
+ Coinbase::Client::CreateAddressRequest
- #valid?
- Coinbase::Client::WalletList
+ #valid?
+ Coinbase::Client::Transfer::EnumAttributeValidator
- #valid?
- Coinbase::Client::FaucetTransaction
+ #valid?
+ Coinbase::Client::Asset
- #valid?
- Coinbase::Client::AddressList
+ #valid?
+ Coinbase::Client::Address
- #valid?
- Coinbase::Client::TransferList
+ #valid?
+ Coinbase::Client::Wallet
- #valid?
- Coinbase::Client::Address
+ #valid?
+ Coinbase::Client::CreateWalletRequest
- #valid?
- Coinbase::Client::Asset
+ #valid?
+ Coinbase::Client::Balance
- #valid?
- Coinbase::Client::CreateAddressRequest
+ #valid?
+ Coinbase::Client::TransferList
- #valid?
- Coinbase::Client::Balance
+ #valid?
+ Coinbase::Client::AddressBalanceList
@@ -4158,8 +4254,8 @@
- #valid?
- Coinbase::Client::CreateWalletRequest
+ #valid?
+ Coinbase::Client::WalletList
@@ -4182,48 +4278,48 @@
diff --git a/lib/coinbase/address.rb b/lib/coinbase/address.rb
index d2028097..891dc351 100644
--- a/lib/coinbase/address.rb
+++ b/lib/coinbase/address.rb
@@ -133,10 +133,16 @@ def transfer(amount, asset_id, destination)
Coinbase::Transfer.new(transfer_model)
end
- # Returns the address as a string.
- # @return [String] The address
+ # Returns a String representation of the Address.
+ # @return [String] a String representation of the Address
def to_s
- address_id
+ "Coinbase::Address{address_id: '#{address_id}', network_id: '#{network_id}', wallet_id: '#{wallet_id}'}"
+ end
+
+ # Same as to_s.
+ # @return [String] a String representation of the Address
+ def inspect
+ to_s
end
# Requests funds for the address from the faucet and returns the faucet transaction.
diff --git a/lib/coinbase/errors.rb b/lib/coinbase/errors.rb
index 860189a2..9fc934c5 100644
--- a/lib/coinbase/errors.rb
+++ b/lib/coinbase/errors.rb
@@ -80,13 +80,16 @@ def self.from_error(err)
end
end
- # The string representation of the error.
+ # Returns a String representation of the APIError.
+ # @return [String] a String representation of the APIError
def to_s
- message = "API Error \n"
- message += "HTTP status code: #{http_code}\n" if http_code
- message += "API error code: #{api_code}\n" if api_code
- message += "API error message: #{api_message}\n" if api_message
- message
+ "APIError{http_code: #{@http_code}, api_code: #{@api_code}, api_message: #{@api_message}}"
+ end
+
+ # Same as to_s.
+ # @return [String] a String representation of the APIError
+ def inspect
+ to_s
end
end
diff --git a/lib/coinbase/faucet_transaction.rb b/lib/coinbase/faucet_transaction.rb
index cd8eb56f..15f1eb80 100644
--- a/lib/coinbase/faucet_transaction.rb
+++ b/lib/coinbase/faucet_transaction.rb
@@ -6,6 +6,8 @@ module Coinbase
# in the native Asset of the Network. Transfers should be created through Wallet#transfer or
# Address#transfer.
class FaucetTransaction
+ # Returns a new FaucetTransaction object. Do not use this method directly - instead, use Address#faucet.
+ # @param model [Coinbase::Client::FaucetTransaction] The underlying FaucetTransaction object
def initialize(model)
@model = model
end
@@ -17,5 +19,24 @@ def initialize(model)
def transaction_hash
model.transaction_hash
end
+
+ # Returns the link to the transaction on the blockchain explorer.
+ # @return [String] The link to the transaction on the blockchain explorer
+ def transaction_link
+ # TODO: Parameterize this by Network.
+ "https://sepolia.basescan.org/tx/#{transaction_hash}"
+ end
+
+ # Returns a String representation of the FaucetTransaction.
+ # @return [String] a String representation of the FaucetTransaction
+ def to_s
+ "Coinbase::FaucetTransaction{transaction_hash: '#{transaction_hash}', transaction_link: '#{transaction_link}'}"
+ end
+
+ # Same as to_s.
+ # @return [String] a String representation of the FaucetTransaction
+ def inspect
+ to_s
+ end
end
end
diff --git a/lib/coinbase/transfer.rb b/lib/coinbase/transfer.rb
index beb1bb96..69ae6158 100644
--- a/lib/coinbase/transfer.rb
+++ b/lib/coinbase/transfer.rb
@@ -77,6 +77,13 @@ def amount
BigDecimal(@model.amount) / BigDecimal(Coinbase::WEI_PER_ETHER.to_s)
end
+ # Returns the link to the transaction on the blockchain explorer.
+ # @return [String] The link to the transaction on the blockchain explorer
+ def transaction_link
+ # TODO: Parameterize this by Network.
+ "https://sepolia.basescan.org/tx/#{transaction_hash}"
+ end
+
# Returns the Unsigned Payload of the Transfer.
# @return [String] The Unsigned Payload
def unsigned_payload
@@ -163,5 +170,20 @@ def wait!(interval_seconds = 0.2, timeout_seconds = 10)
self
end
+
+ # 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}', " +
+ "transaction_link: '#{transaction_link}', status: '#{status}'}"
+ end
+
+ # Same as to_s.
+ # @return [String] a String representation of the Transfer
+ def inspect
+ to_s
+ end
end
end
diff --git a/lib/coinbase/user.rb b/lib/coinbase/user.rb
index 895099a6..a519075c 100644
--- a/lib/coinbase/user.rb
+++ b/lib/coinbase/user.rb
@@ -70,10 +70,10 @@ def list_wallet_ids
# Coinbase.configuration.backup_file_path.
#
# @param wallet [Coinbase::Wallet] The wallet model to save.
- # @param encrypt [bool] Boolean representing whether the backup persisted to local file system should be encrypted
- # or not. Data is unencrypted by default.
+ # @param encrypt [bool] (Optional) Boolean representing whether the backup persisted to local file system should be
+ # encrypted or not. Data is unencrypted by default.
# @return [Coinbase::Wallet] the saved wallet.
- def save_wallet(wallet, encrypt = false)
+ def save_wallet(wallet, encrypt: false)
existing_seeds_in_store = existing_seeds
data = wallet.export
seed_to_store = data.seed
@@ -138,6 +138,18 @@ def load_wallets
wallets
end
+ # Returns a string representation of the User.
+ # @return [String] a string representation of the User
+ def to_s
+ "Coinbase::User{user_id: '#{user_id}'}"
+ end
+
+ # Same as to_s.
+ # @return [String] a string representation of the User
+ def inspect
+ to_s
+ end
+
private
def addresses_api
diff --git a/lib/coinbase/wallet.rb b/lib/coinbase/wallet.rb
index 4f1f0efa..76af2cae 100644
--- a/lib/coinbase/wallet.rb
+++ b/lib/coinbase/wallet.rb
@@ -161,6 +161,19 @@ def export
Data.new(wallet_id: wallet_id, seed: @master.seed_hex)
end
+ # 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}'}"
+ end
+
+ # Same as to_s.
+ # @return [String] a String representation of the Wallet
+ def inspect
+ to_s
+ end
+
# The data required to recreate a Wallet.
class Data
attr_reader :wallet_id, :seed
diff --git a/spec/unit/coinbase/address_spec.rb b/spec/unit/coinbase/address_spec.rb
index 514dd897..532efc86 100644
--- a/spec/unit/coinbase/address_spec.rb
+++ b/spec/unit/coinbase/address_spec.rb
@@ -383,10 +383,4 @@
end
end
end
-
- describe '#to_s' do
- it 'returns the address as a string' do
- expect(address.to_s).to eq(address_id)
- end
- end
end
diff --git a/spec/unit/coinbase/user_spec.rb b/spec/unit/coinbase/user_spec.rb
index cc55344c..0ee9fc86 100644
--- a/spec/unit/coinbase/user_spec.rb
+++ b/spec/unit/coinbase/user_spec.rb
@@ -183,7 +183,7 @@
end
it 'saves the Wallet data when encryption is true' do
- saved_wallet = user.save_wallet(seed_wallet, true)
+ saved_wallet = user.save_wallet(seed_wallet, encrypt: true)
# Verify that the file has new wallet.
stored_seed_data = File.read(Coinbase.configuration.backup_file_path)
wallets = JSON.parse(stored_seed_data)
|