Skip to content

Commit

Permalink
Merge pull request #196 from coinbase/v0.6.0
Browse files Browse the repository at this point in the history
V0.6.0 Release
  • Loading branch information
alex-stone authored Sep 18, 2024
2 parents c07ac73 + 7a4393d commit 3b5de66
Show file tree
Hide file tree
Showing 39 changed files with 3,757 additions and 169 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.6.0] - 2024-09-18

### Added
- Add `deploy_token` support for deploying ERC20 tokens from MPC / dev-managed wallets.
- Allow for calling `invoke_contract` without an ABI for known contract types (ERC20, ERC721, and
ERC1155).
- Fix handling when invoking a contract that is not-payable.

## [0.5.0] - 2024-09-11

### Added
Expand Down
27 changes: 26 additions & 1 deletion lib/coinbase/address/wallet_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def trade(amount, from_asset_id, to_asset_id)
# @param asset_id [Symbol] (Optional) The ID of the Asset to send to a payable contract method.
# The Asset must be a denomination of the native Asset. For Ethereum, :eth, :gwei, and :wei are supported.
# @return [Coinbase::ContractInvocation] The contract invocation object.
def invoke_contract(contract_address:, abi:, method:, args:, amount: nil, asset_id: nil)
def invoke_contract(contract_address:, method:, args:, abi: nil, amount: nil, asset_id: nil)
ensure_can_sign!
ensure_sufficient_balance!(amount, asset_id) if amount && asset_id

Expand All @@ -130,6 +130,31 @@ def invoke_contract(contract_address:, abi:, method:, args:, amount: nil, asset_
invocation
end

# Deploys a new ERC20 token contract with the given name, symbol, and total supply.
# @param name [String] The name of the token.
# @param symbol [String] The symbol of the token.
# @param total_supply [Integer, BigDecimal] The total supply of the token, denominated in
# whole units.
# @return [Coinbase::SmartContract] The deployed token contract.
# @raise [AddressCannotSignError] if the Address does not have a private key backing it.
def deploy_token(name:, symbol:, total_supply:)
ensure_can_sign!

smart_contract = SmartContract.create_token_contract(
address_id: id,
wallet_id: wallet_id,
name: name,
symbol: symbol,
total_supply: total_supply
)

return smart_contract if Coinbase.use_server_signer?

smart_contract.sign(@key)
smart_contract.deploy!
smart_contract
end

# Signs the given unsigned payload.
# @param unsigned_payload [String] The hex-encoded hashed unsigned payload for the Address to sign.
# @return [Coinbase::PayloadSignature] The payload signature
Expand Down
13 changes: 13 additions & 0 deletions lib/coinbase/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
Coinbase::Client.autoload :CreateContractInvocationRequest, 'coinbase/client/models/create_contract_invocation_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'
Coinbase::Client.autoload :CreateStakingOperationRequest, 'coinbase/client/models/create_staking_operation_request'
Coinbase::Client.autoload :CreateTradeRequest, 'coinbase/client/models/create_trade_request'
Coinbase::Client.autoload :CreateTransferRequest, 'coinbase/client/models/create_transfer_request'
Coinbase::Client.autoload :CreateWalletRequest, 'coinbase/client/models/create_wallet_request'
Coinbase::Client.autoload :CreateWalletRequestWallet, 'coinbase/client/models/create_wallet_request_wallet'
Coinbase::Client.autoload :CreateWebhookRequest, 'coinbase/client/models/create_webhook_request'
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'
Coinbase::Client.autoload :Error, 'coinbase/client/models/error'
Expand All @@ -58,6 +60,7 @@
Coinbase::Client.autoload :FetchStakingRewardsRequest, 'coinbase/client/models/fetch_staking_rewards_request'
Coinbase::Client.autoload :GetStakingContextRequest, 'coinbase/client/models/get_staking_context_request'
Coinbase::Client.autoload :HistoricalBalance, 'coinbase/client/models/historical_balance'
Coinbase::Client.autoload :NFTContractOptions, 'coinbase/client/models/nft_contract_options'
Coinbase::Client.autoload :Network, 'coinbase/client/models/network'
Coinbase::Client.autoload :NetworkIdentifier, 'coinbase/client/models/network_identifier'
Coinbase::Client.autoload :PayloadSignature, 'coinbase/client/models/payload_signature'
Expand All @@ -72,6 +75,10 @@
Coinbase::Client.autoload :SignatureCreationEvent, 'coinbase/client/models/signature_creation_event'
Coinbase::Client.autoload :SignatureCreationEventResult, 'coinbase/client/models/signature_creation_event_result'
Coinbase::Client.autoload :SignedVoluntaryExitMessageMetadata, 'coinbase/client/models/signed_voluntary_exit_message_metadata'
Coinbase::Client.autoload :SmartContract, 'coinbase/client/models/smart_contract'
Coinbase::Client.autoload :SmartContractList, 'coinbase/client/models/smart_contract_list'
Coinbase::Client.autoload :SmartContractOptions, 'coinbase/client/models/smart_contract_options'
Coinbase::Client.autoload :SmartContractType, 'coinbase/client/models/smart_contract_type'
Coinbase::Client.autoload :SponsoredSend, 'coinbase/client/models/sponsored_send'
Coinbase::Client.autoload :StakingBalance, 'coinbase/client/models/staking_balance'
Coinbase::Client.autoload :StakingContext, 'coinbase/client/models/staking_context'
Expand All @@ -81,6 +88,7 @@
Coinbase::Client.autoload :StakingReward, 'coinbase/client/models/staking_reward'
Coinbase::Client.autoload :StakingRewardFormat, 'coinbase/client/models/staking_reward_format'
Coinbase::Client.autoload :StakingRewardUSDValue, 'coinbase/client/models/staking_reward_usd_value'
Coinbase::Client.autoload :TokenContractOptions, 'coinbase/client/models/token_contract_options'
Coinbase::Client.autoload :Trade, 'coinbase/client/models/trade'
Coinbase::Client.autoload :TradeList, 'coinbase/client/models/trade_list'
Coinbase::Client.autoload :Transaction, 'coinbase/client/models/transaction'
Expand All @@ -89,6 +97,7 @@
Coinbase::Client.autoload :Transfer, 'coinbase/client/models/transfer'
Coinbase::Client.autoload :TransferList, 'coinbase/client/models/transfer_list'
Coinbase::Client.autoload :UpdateWebhookRequest, 'coinbase/client/models/update_webhook_request'
Coinbase::Client.autoload :User, 'coinbase/client/models/user'
Coinbase::Client.autoload :Validator, 'coinbase/client/models/validator'
Coinbase::Client.autoload :ValidatorDetails, 'coinbase/client/models/validator_details'
Coinbase::Client.autoload :ValidatorList, 'coinbase/client/models/validator_list'
Expand All @@ -98,7 +107,9 @@
Coinbase::Client.autoload :Webhook, 'coinbase/client/models/webhook'
Coinbase::Client.autoload :WebhookEventFilter, 'coinbase/client/models/webhook_event_filter'
Coinbase::Client.autoload :WebhookEventType, 'coinbase/client/models/webhook_event_type'
Coinbase::Client.autoload :WebhookEventTypeFilter, 'coinbase/client/models/webhook_event_type_filter'
Coinbase::Client.autoload :WebhookList, 'coinbase/client/models/webhook_list'
Coinbase::Client.autoload :WebhookWalletActivityFilter, 'coinbase/client/models/webhook_wallet_activity_filter'

# APIs
Coinbase::Client.autoload :AddressesApi, 'coinbase/client/api/addresses_api'
Expand All @@ -109,9 +120,11 @@
Coinbase::Client.autoload :ExternalAddressesApi, 'coinbase/client/api/external_addresses_api'
Coinbase::Client.autoload :NetworksApi, 'coinbase/client/api/networks_api'
Coinbase::Client.autoload :ServerSignersApi, 'coinbase/client/api/server_signers_api'
Coinbase::Client.autoload :SmartContractsApi, 'coinbase/client/api/smart_contracts_api'
Coinbase::Client.autoload :StakeApi, 'coinbase/client/api/stake_api'
Coinbase::Client.autoload :TradesApi, 'coinbase/client/api/trades_api'
Coinbase::Client.autoload :TransfersApi, 'coinbase/client/api/transfers_api'
Coinbase::Client.autoload :UsersApi, 'coinbase/client/api/users_api'
Coinbase::Client.autoload :ValidatorsApi, 'coinbase/client/api/validators_api'
Coinbase::Client.autoload :WalletStakeApi, 'coinbase/client/api/wallet_stake_api'
Coinbase::Client.autoload :WalletsApi, 'coinbase/client/api/wallets_api'
Expand Down
Loading

0 comments on commit 3b5de66

Please sign in to comment.