Skip to content

Commit

Permalink
feat: Support registering and updating external smart contracts (#220)
Browse files Browse the repository at this point in the history
### What changed? Why?
This starts to add support for registering external smart contracts
with CDP.

This will enable developers to use these register smart contracts
to invoke, read, and create webhooks associated with the contract!

### Testing
```ruby
# Deploy a token and get an ERC20 ABI ref
smart_contract = wallet.deploy_token(name: "Test Coin", symbol: "TEST", total_supply: 1000)
smart_contract.wait!

asset = Coinbase::Asset.fetch(:base_sepolia, :usdc)

# Register an external contract w/ a known ABI
external_contract = Coinbase::SmartContract.register(
  network: Coinbase::Network::BASE_SEPOLIA,
  contract_address: asset.address_id,
  name: "USDC YO",
  abi: smart_contract.abi
)

external_contract.update(name: "Base Sepolia USDC Contract")
```

#### Qualified Impact
<!-- Please evaluate what components could be affected and what the
impact would be if there was an
error. How would this error be resolved, e.g. rollback a deploy, push a
new fix, disable a feature
flag, etc... -->
  • Loading branch information
alex-stone authored Dec 19, 2024
1 parent 99d6197 commit 8bb7c70
Show file tree
Hide file tree
Showing 146 changed files with 1,844 additions and 525 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
* Add support for fetching address reputation.
* Add `network_id` to `WalletData` so that it is saved with the seed data and surfaced via the export function
* Add support for registering, updating, and listing smart contracts that are
deployed external to CDP.

## [0.12.0] - Skipped

Expand Down
6 changes: 4 additions & 2 deletions lib/coinbase/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The version of the OpenAPI document: 0.0.1-alpha
Generated by: https://openapi-generator.tech
Generator version: 7.9.0
Generator version: 7.10.0
=end

Expand All @@ -27,16 +27,17 @@
Coinbase::Client.autoload :Asset, 'coinbase/client/models/asset'
Coinbase::Client.autoload :Balance, 'coinbase/client/models/balance'
Coinbase::Client.autoload :BroadcastContractInvocationRequest, 'coinbase/client/models/broadcast_contract_invocation_request'
Coinbase::Client.autoload :BroadcastExternalTransferRequest, 'coinbase/client/models/broadcast_external_transfer_request'
Coinbase::Client.autoload :BroadcastStakingOperationRequest, 'coinbase/client/models/broadcast_staking_operation_request'
Coinbase::Client.autoload :BroadcastTradeRequest, 'coinbase/client/models/broadcast_trade_request'
Coinbase::Client.autoload :BroadcastTransferRequest, 'coinbase/client/models/broadcast_transfer_request'
Coinbase::Client.autoload :BuildStakingOperationRequest, 'coinbase/client/models/build_staking_operation_request'
Coinbase::Client.autoload :ContractEvent, 'coinbase/client/models/contract_event'
Coinbase::Client.autoload :ContractEventList, 'coinbase/client/models/contract_event_list'
Coinbase::Client.autoload :ContractInvocation, 'coinbase/client/models/contract_invocation'
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 :CreateExternalTransferRequest, 'coinbase/client/models/create_external_transfer_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'
Expand Down Expand Up @@ -116,6 +117,7 @@
Coinbase::Client.autoload :TransactionType, 'coinbase/client/models/transaction_type'
Coinbase::Client.autoload :Transfer, 'coinbase/client/models/transfer'
Coinbase::Client.autoload :TransferList, 'coinbase/client/models/transfer_list'
Coinbase::Client.autoload :UpdateSmartContractRequest, 'coinbase/client/models/update_smart_contract_request'
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'
Expand Down
20 changes: 10 additions & 10 deletions lib/coinbase/client/api/addresses_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The version of the OpenAPI document: 0.0.1-alpha
Generated by: https://openapi-generator.tech
Generator version: 7.9.0
Generator version: 7.10.0
=end

Expand Down Expand Up @@ -70,7 +70,7 @@ def create_address_with_http_info(wallet_id, opts = {})
return_type = opts[:debug_return_type] || 'Address'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey']

new_options = opts.merge(
:operation => :"AddressesApi.create_address",
Expand Down Expand Up @@ -146,7 +146,7 @@ def create_payload_signature_with_http_info(wallet_id, address_id, opts = {})
return_type = opts[:debug_return_type] || 'PayloadSignature'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey']

new_options = opts.merge(
:operation => :"AddressesApi.create_payload_signature",
Expand Down Expand Up @@ -215,7 +215,7 @@ def get_address_with_http_info(wallet_id, address_id, opts = {})
return_type = opts[:debug_return_type] || 'Address'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"AddressesApi.get_address",
Expand Down Expand Up @@ -290,7 +290,7 @@ def get_address_balance_with_http_info(wallet_id, address_id, asset_id, opts = {
return_type = opts[:debug_return_type] || 'Balance'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"AddressesApi.get_address_balance",
Expand Down Expand Up @@ -365,7 +365,7 @@ def get_payload_signature_with_http_info(wallet_id, address_id, payload_signatur
return_type = opts[:debug_return_type] || 'PayloadSignature'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"AddressesApi.get_payload_signature",
Expand Down Expand Up @@ -441,7 +441,7 @@ def list_address_balances_with_http_info(wallet_id, address_id, opts = {})
return_type = opts[:debug_return_type] || 'AddressBalanceList'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"AddressesApi.list_address_balances",
Expand Down Expand Up @@ -514,7 +514,7 @@ def list_addresses_with_http_info(wallet_id, opts = {})
return_type = opts[:debug_return_type] || 'AddressList'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"AddressesApi.list_addresses",
Expand Down Expand Up @@ -593,7 +593,7 @@ def list_payload_signatures_with_http_info(wallet_id, address_id, opts = {})
return_type = opts[:debug_return_type] || 'PayloadSignatureList'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"AddressesApi.list_payload_signatures",
Expand Down Expand Up @@ -665,7 +665,7 @@ def request_faucet_funds_with_http_info(wallet_id, address_id, opts = {})
return_type = opts[:debug_return_type] || 'FaucetTransaction'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey']

new_options = opts.merge(
:operation => :"AddressesApi.request_faucet_funds",
Expand Down
4 changes: 2 additions & 2 deletions lib/coinbase/client/api/assets_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The version of the OpenAPI document: 0.0.1-alpha
Generated by: https://openapi-generator.tech
Generator version: 7.9.0
Generator version: 7.10.0
=end

Expand Down Expand Up @@ -69,7 +69,7 @@ def get_asset_with_http_info(network_id, asset_id, opts = {})
return_type = opts[:debug_return_type] || 'Asset'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"AssetsApi.get_asset",
Expand Down
4 changes: 2 additions & 2 deletions lib/coinbase/client/api/balance_history_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The version of the OpenAPI document: 0.0.1-alpha
Generated by: https://openapi-generator.tech
Generator version: 7.9.0
Generator version: 7.10.0
=end

Expand Down Expand Up @@ -85,7 +85,7 @@ def list_address_historical_balance_with_http_info(network_id, address_id, asset
return_type = opts[:debug_return_type] || 'AddressHistoricalBalanceList'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"BalanceHistoryApi.list_address_historical_balance",
Expand Down
4 changes: 2 additions & 2 deletions lib/coinbase/client/api/contract_events_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The version of the OpenAPI document: 0.0.1-alpha
Generated by: https://openapi-generator.tech
Generator version: 7.9.0
Generator version: 7.10.0
=end

Expand Down Expand Up @@ -107,7 +107,7 @@ def list_contract_events_with_http_info(network_id, protocol_name, contract_addr
return_type = opts[:debug_return_type] || 'ContractEventList'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"ContractEventsApi.list_contract_events",
Expand Down
10 changes: 5 additions & 5 deletions lib/coinbase/client/api/contract_invocations_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The version of the OpenAPI document: 0.0.1-alpha
Generated by: https://openapi-generator.tech
Generator version: 7.9.0
Generator version: 7.10.0
=end

Expand Down Expand Up @@ -86,7 +86,7 @@ def broadcast_contract_invocation_with_http_info(wallet_id, address_id, contract
return_type = opts[:debug_return_type] || 'ContractInvocation'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey']

new_options = opts.merge(
:operation => :"ContractInvocationsApi.broadcast_contract_invocation",
Expand Down Expand Up @@ -166,7 +166,7 @@ def create_contract_invocation_with_http_info(wallet_id, address_id, create_cont
return_type = opts[:debug_return_type] || 'ContractInvocation'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey']

new_options = opts.merge(
:operation => :"ContractInvocationsApi.create_contract_invocation",
Expand Down Expand Up @@ -241,7 +241,7 @@ def get_contract_invocation_with_http_info(wallet_id, address_id, contract_invoc
return_type = opts[:debug_return_type] || 'ContractInvocation'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"ContractInvocationsApi.get_contract_invocation",
Expand Down Expand Up @@ -320,7 +320,7 @@ def list_contract_invocations_with_http_info(wallet_id, address_id, opts = {})
return_type = opts[:debug_return_type] || 'ContractInvocationList'

# auth_names
auth_names = opts[:debug_auth_names] || []
auth_names = opts[:debug_auth_names] || ['apiKey', 'session']

new_options = opts.merge(
:operation => :"ContractInvocationsApi.list_contract_invocations",
Expand Down
Loading

0 comments on commit 8bb7c70

Please sign in to comment.