Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stone/funding #212

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/coinbase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
require_relative 'coinbase/constants'
require_relative 'coinbase/contract_event'
require_relative 'coinbase/contract_invocation'
require_relative 'coinbase/crypto_amount'
require_relative 'coinbase/destination'
require_relative 'coinbase/errors'
require_relative 'coinbase/faucet_transaction'
require_relative 'coinbase/middleware'
require_relative 'coinbase/network'
require_relative 'coinbase/fund_operation'
require_relative 'coinbase/fund_quote'
require_relative 'coinbase/pagination'
require_relative 'coinbase/payload_signature'
require_relative 'coinbase/trade'
Expand Down
28 changes: 28 additions & 0 deletions lib/coinbase/address/wallet_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,34 @@ def sign_payload(unsigned_payload:)
)
end

# Funds the address from your account on the Coinbase Platform for the given amount of the given Asset.
# @param amount [Integer, Float, BigDecimal] The amount of the Asset to fund the wallet with.
# @param asset_id [Symbol] The ID of the Asset to trade from. For Ether, :eth, :gwei, and :wei are supported.
# @return [Coinbase::FundOperation] The FundOperation object.
def fund(amount, asset_id, options: {})
FundOperation.create(
address_id: id,
amount: amount,
asset_id: asset_id,
network: network,
wallet_id: wallet_id
)
end

# Gets a quote for a fund operation to fund the address from your Coinbase platform,
# account for the amount of the specified Asset.
# @param asset_id [Symbol] The ID of the Asset to trade from. For Ether, :eth, :gwei, and :wei are supported.
# @return [Coinbase::FundQuote] The FundQuote object.
def quote_fund(amount, asset_id, options: {})
FundQuote.create(
address_id: id,
amount: amount,
asset_id: asset_id,
network: network,
wallet_id: wallet_id
)
end

# Stakes the given amount of the given Asset. The stake operation
# may take a few minutes to complete in the case when infrastructure is spun up.
# @param amount [Integer, Float, BigDecimal] The amount of the Asset to stake.
Expand Down
10 changes: 9 additions & 1 deletion lib/coinbase/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
Coinbase::Client.autoload :ContractInvocationList, 'coinbase/client/models/contract_invocation_list'
Coinbase::Client.autoload :CreateAddressRequest, 'coinbase/client/models/create_address_request'
Coinbase::Client.autoload :CreateContractInvocationRequest, 'coinbase/client/models/create_contract_invocation_request'
Coinbase::Client.autoload :CreateFundOperationRequest, 'coinbase/client/models/create_fund_operation_request'
Coinbase::Client.autoload :CreateFundQuoteRequest, 'coinbase/client/models/create_fund_quote_request'
Coinbase::Client.autoload :CreatePayloadSignatureRequest, 'coinbase/client/models/create_payload_signature_request'
Coinbase::Client.autoload :CreateServerSignerRequest, 'coinbase/client/models/create_server_signer_request'
Coinbase::Client.autoload :CreateSmartContractRequest, 'coinbase/client/models/create_smart_contract_request'
Expand All @@ -45,6 +47,7 @@
Coinbase::Client.autoload :CreateWalletRequestWallet, 'coinbase/client/models/create_wallet_request_wallet'
Coinbase::Client.autoload :CreateWalletWebhookRequest, 'coinbase/client/models/create_wallet_webhook_request'
Coinbase::Client.autoload :CreateWebhookRequest, 'coinbase/client/models/create_webhook_request'
Coinbase::Client.autoload :CryptoAmount, 'coinbase/client/models/crypto_amount'
Coinbase::Client.autoload :DeploySmartContractRequest, 'coinbase/client/models/deploy_smart_contract_request'
Coinbase::Client.autoload :ERC20TransferEvent, 'coinbase/client/models/erc20_transfer_event'
Coinbase::Client.autoload :ERC721TransferEvent, 'coinbase/client/models/erc721_transfer_event'
Expand All @@ -60,6 +63,11 @@
Coinbase::Client.autoload :FetchHistoricalStakingBalances200Response, 'coinbase/client/models/fetch_historical_staking_balances200_response'
Coinbase::Client.autoload :FetchStakingRewards200Response, 'coinbase/client/models/fetch_staking_rewards200_response'
Coinbase::Client.autoload :FetchStakingRewardsRequest, 'coinbase/client/models/fetch_staking_rewards_request'
Coinbase::Client.autoload :FiatAmount, 'coinbase/client/models/fiat_amount'
Coinbase::Client.autoload :FundOperation, 'coinbase/client/models/fund_operation'
Coinbase::Client.autoload :FundOperationFees, 'coinbase/client/models/fund_operation_fees'
Coinbase::Client.autoload :FundOperationList, 'coinbase/client/models/fund_operation_list'
Coinbase::Client.autoload :FundQuote, 'coinbase/client/models/fund_quote'
Coinbase::Client.autoload :GetStakingContextRequest, 'coinbase/client/models/get_staking_context_request'
Coinbase::Client.autoload :HistoricalBalance, 'coinbase/client/models/historical_balance'
Coinbase::Client.autoload :MultiTokenContractOptions, 'coinbase/client/models/multi_token_contract_options'
Expand All @@ -68,7 +76,6 @@
Coinbase::Client.autoload :NetworkIdentifier, 'coinbase/client/models/network_identifier'
Coinbase::Client.autoload :OnchainName, 'coinbase/client/models/onchain_name'
Coinbase::Client.autoload :OnchainNameList, 'coinbase/client/models/onchain_name_list'
Coinbase::Client.autoload :OnchainNameTextRecordsInner, 'coinbase/client/models/onchain_name_text_records_inner'
Coinbase::Client.autoload :PayloadSignature, 'coinbase/client/models/payload_signature'
Coinbase::Client.autoload :PayloadSignatureList, 'coinbase/client/models/payload_signature_list'
Coinbase::Client.autoload :ReadContractRequest, 'coinbase/client/models/read_contract_request'
Expand Down Expand Up @@ -127,6 +134,7 @@
Coinbase::Client.autoload :ContractEventsApi, 'coinbase/client/api/contract_events_api'
Coinbase::Client.autoload :ContractInvocationsApi, 'coinbase/client/api/contract_invocations_api'
Coinbase::Client.autoload :ExternalAddressesApi, 'coinbase/client/api/external_addresses_api'
Coinbase::Client.autoload :FundApi, 'coinbase/client/api/fund_api'
Coinbase::Client.autoload :NetworksApi, 'coinbase/client/api/networks_api'
Coinbase::Client.autoload :OnchainIdentityApi, 'coinbase/client/api/onchain_identity_api'
Coinbase::Client.autoload :ServerSignersApi, 'coinbase/client/api/server_signers_api'
Expand Down
Loading
Loading