coinbase-sdk 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/coinbase/address/wallet_address.rb +26 -1
- data/lib/coinbase/client/api/smart_contracts_api.rb +332 -0
- data/lib/coinbase/client/api/stake_api.rb +0 -8
- data/lib/coinbase/client/api/users_api.rb +79 -0
- data/lib/coinbase/client/api/validators_api.rb +4 -4
- data/lib/coinbase/client/api/wallets_api.rb +4 -4
- data/lib/coinbase/client/models/create_smart_contract_request.rb +259 -0
- data/lib/coinbase/client/models/create_webhook_request.rb +10 -8
- data/lib/coinbase/client/models/deploy_smart_contract_request.rb +222 -0
- data/lib/coinbase/client/models/feature.rb +43 -0
- data/lib/coinbase/client/models/nft_contract_options.rb +240 -0
- data/lib/coinbase/client/models/smart_contract.rb +378 -0
- data/lib/coinbase/client/models/smart_contract_list.rb +257 -0
- data/lib/coinbase/client/models/smart_contract_options.rb +106 -0
- data/lib/coinbase/client/models/smart_contract_type.rb +41 -0
- data/lib/coinbase/client/models/staking_balance.rb +2 -2
- data/lib/coinbase/client/models/staking_reward.rb +2 -2
- data/lib/coinbase/client/models/token_contract_options.rb +257 -0
- data/lib/coinbase/client/models/update_webhook_request.rb +10 -8
- data/lib/coinbase/client/models/user.rb +231 -0
- data/lib/coinbase/client/models/webhook.rb +10 -1
- data/lib/coinbase/client/models/webhook_event_type.rb +2 -1
- data/lib/coinbase/client/models/webhook_event_type_filter.rb +105 -0
- data/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +228 -0
- data/lib/coinbase/client.rb +13 -0
- data/lib/coinbase/contract_invocation.rb +16 -17
- data/lib/coinbase/smart_contract.rb +216 -45
- data/lib/coinbase/transaction.rb +3 -0
- data/lib/coinbase/transfer.rb +1 -1
- data/lib/coinbase/version.rb +1 -1
- data/lib/coinbase/wallet.rb +11 -2
- metadata +16 -2
data/lib/coinbase/client.rb
CHANGED
@@ -37,12 +37,14 @@ Coinbase::Client.autoload :CreateAddressRequest, 'coinbase/client/models/create_
|
|
37
37
|
Coinbase::Client.autoload :CreateContractInvocationRequest, 'coinbase/client/models/create_contract_invocation_request'
|
38
38
|
Coinbase::Client.autoload :CreatePayloadSignatureRequest, 'coinbase/client/models/create_payload_signature_request'
|
39
39
|
Coinbase::Client.autoload :CreateServerSignerRequest, 'coinbase/client/models/create_server_signer_request'
|
40
|
+
Coinbase::Client.autoload :CreateSmartContractRequest, 'coinbase/client/models/create_smart_contract_request'
|
40
41
|
Coinbase::Client.autoload :CreateStakingOperationRequest, 'coinbase/client/models/create_staking_operation_request'
|
41
42
|
Coinbase::Client.autoload :CreateTradeRequest, 'coinbase/client/models/create_trade_request'
|
42
43
|
Coinbase::Client.autoload :CreateTransferRequest, 'coinbase/client/models/create_transfer_request'
|
43
44
|
Coinbase::Client.autoload :CreateWalletRequest, 'coinbase/client/models/create_wallet_request'
|
44
45
|
Coinbase::Client.autoload :CreateWalletRequestWallet, 'coinbase/client/models/create_wallet_request_wallet'
|
45
46
|
Coinbase::Client.autoload :CreateWebhookRequest, 'coinbase/client/models/create_webhook_request'
|
47
|
+
Coinbase::Client.autoload :DeploySmartContractRequest, 'coinbase/client/models/deploy_smart_contract_request'
|
46
48
|
Coinbase::Client.autoload :ERC20TransferEvent, 'coinbase/client/models/erc20_transfer_event'
|
47
49
|
Coinbase::Client.autoload :ERC721TransferEvent, 'coinbase/client/models/erc721_transfer_event'
|
48
50
|
Coinbase::Client.autoload :Error, 'coinbase/client/models/error'
|
@@ -58,6 +60,7 @@ Coinbase::Client.autoload :FetchStakingRewards200Response, 'coinbase/client/mode
|
|
58
60
|
Coinbase::Client.autoload :FetchStakingRewardsRequest, 'coinbase/client/models/fetch_staking_rewards_request'
|
59
61
|
Coinbase::Client.autoload :GetStakingContextRequest, 'coinbase/client/models/get_staking_context_request'
|
60
62
|
Coinbase::Client.autoload :HistoricalBalance, 'coinbase/client/models/historical_balance'
|
63
|
+
Coinbase::Client.autoload :NFTContractOptions, 'coinbase/client/models/nft_contract_options'
|
61
64
|
Coinbase::Client.autoload :Network, 'coinbase/client/models/network'
|
62
65
|
Coinbase::Client.autoload :NetworkIdentifier, 'coinbase/client/models/network_identifier'
|
63
66
|
Coinbase::Client.autoload :PayloadSignature, 'coinbase/client/models/payload_signature'
|
@@ -72,6 +75,10 @@ Coinbase::Client.autoload :ServerSignerList, 'coinbase/client/models/server_sign
|
|
72
75
|
Coinbase::Client.autoload :SignatureCreationEvent, 'coinbase/client/models/signature_creation_event'
|
73
76
|
Coinbase::Client.autoload :SignatureCreationEventResult, 'coinbase/client/models/signature_creation_event_result'
|
74
77
|
Coinbase::Client.autoload :SignedVoluntaryExitMessageMetadata, 'coinbase/client/models/signed_voluntary_exit_message_metadata'
|
78
|
+
Coinbase::Client.autoload :SmartContract, 'coinbase/client/models/smart_contract'
|
79
|
+
Coinbase::Client.autoload :SmartContractList, 'coinbase/client/models/smart_contract_list'
|
80
|
+
Coinbase::Client.autoload :SmartContractOptions, 'coinbase/client/models/smart_contract_options'
|
81
|
+
Coinbase::Client.autoload :SmartContractType, 'coinbase/client/models/smart_contract_type'
|
75
82
|
Coinbase::Client.autoload :SponsoredSend, 'coinbase/client/models/sponsored_send'
|
76
83
|
Coinbase::Client.autoload :StakingBalance, 'coinbase/client/models/staking_balance'
|
77
84
|
Coinbase::Client.autoload :StakingContext, 'coinbase/client/models/staking_context'
|
@@ -81,6 +88,7 @@ Coinbase::Client.autoload :StakingOperationMetadata, 'coinbase/client/models/sta
|
|
81
88
|
Coinbase::Client.autoload :StakingReward, 'coinbase/client/models/staking_reward'
|
82
89
|
Coinbase::Client.autoload :StakingRewardFormat, 'coinbase/client/models/staking_reward_format'
|
83
90
|
Coinbase::Client.autoload :StakingRewardUSDValue, 'coinbase/client/models/staking_reward_usd_value'
|
91
|
+
Coinbase::Client.autoload :TokenContractOptions, 'coinbase/client/models/token_contract_options'
|
84
92
|
Coinbase::Client.autoload :Trade, 'coinbase/client/models/trade'
|
85
93
|
Coinbase::Client.autoload :TradeList, 'coinbase/client/models/trade_list'
|
86
94
|
Coinbase::Client.autoload :Transaction, 'coinbase/client/models/transaction'
|
@@ -89,6 +97,7 @@ Coinbase::Client.autoload :TransactionType, 'coinbase/client/models/transaction_
|
|
89
97
|
Coinbase::Client.autoload :Transfer, 'coinbase/client/models/transfer'
|
90
98
|
Coinbase::Client.autoload :TransferList, 'coinbase/client/models/transfer_list'
|
91
99
|
Coinbase::Client.autoload :UpdateWebhookRequest, 'coinbase/client/models/update_webhook_request'
|
100
|
+
Coinbase::Client.autoload :User, 'coinbase/client/models/user'
|
92
101
|
Coinbase::Client.autoload :Validator, 'coinbase/client/models/validator'
|
93
102
|
Coinbase::Client.autoload :ValidatorDetails, 'coinbase/client/models/validator_details'
|
94
103
|
Coinbase::Client.autoload :ValidatorList, 'coinbase/client/models/validator_list'
|
@@ -98,7 +107,9 @@ Coinbase::Client.autoload :WalletList, 'coinbase/client/models/wallet_list'
|
|
98
107
|
Coinbase::Client.autoload :Webhook, 'coinbase/client/models/webhook'
|
99
108
|
Coinbase::Client.autoload :WebhookEventFilter, 'coinbase/client/models/webhook_event_filter'
|
100
109
|
Coinbase::Client.autoload :WebhookEventType, 'coinbase/client/models/webhook_event_type'
|
110
|
+
Coinbase::Client.autoload :WebhookEventTypeFilter, 'coinbase/client/models/webhook_event_type_filter'
|
101
111
|
Coinbase::Client.autoload :WebhookList, 'coinbase/client/models/webhook_list'
|
112
|
+
Coinbase::Client.autoload :WebhookWalletActivityFilter, 'coinbase/client/models/webhook_wallet_activity_filter'
|
102
113
|
|
103
114
|
# APIs
|
104
115
|
Coinbase::Client.autoload :AddressesApi, 'coinbase/client/api/addresses_api'
|
@@ -109,9 +120,11 @@ Coinbase::Client.autoload :ContractInvocationsApi, 'coinbase/client/api/contract
|
|
109
120
|
Coinbase::Client.autoload :ExternalAddressesApi, 'coinbase/client/api/external_addresses_api'
|
110
121
|
Coinbase::Client.autoload :NetworksApi, 'coinbase/client/api/networks_api'
|
111
122
|
Coinbase::Client.autoload :ServerSignersApi, 'coinbase/client/api/server_signers_api'
|
123
|
+
Coinbase::Client.autoload :SmartContractsApi, 'coinbase/client/api/smart_contracts_api'
|
112
124
|
Coinbase::Client.autoload :StakeApi, 'coinbase/client/api/stake_api'
|
113
125
|
Coinbase::Client.autoload :TradesApi, 'coinbase/client/api/trades_api'
|
114
126
|
Coinbase::Client.autoload :TransfersApi, 'coinbase/client/api/transfers_api'
|
127
|
+
Coinbase::Client.autoload :UsersApi, 'coinbase/client/api/users_api'
|
115
128
|
Coinbase::Client.autoload :ValidatorsApi, 'coinbase/client/api/validators_api'
|
116
129
|
Coinbase::Client.autoload :WalletStakeApi, 'coinbase/client/api/wallet_stake_api'
|
117
130
|
Coinbase::Client.autoload :WalletsApi, 'coinbase/client/api/wallets_api'
|
@@ -25,31 +25,30 @@ module Coinbase
|
|
25
25
|
address_id:,
|
26
26
|
wallet_id:,
|
27
27
|
contract_address:,
|
28
|
-
abi:,
|
29
28
|
method:,
|
30
|
-
amount:,
|
31
|
-
asset_id:,
|
32
29
|
network:,
|
33
|
-
args: {}
|
30
|
+
args: {},
|
31
|
+
amount: nil,
|
32
|
+
abi: nil,
|
33
|
+
asset_id: nil
|
34
34
|
)
|
35
|
-
|
35
|
+
req = {
|
36
|
+
method: method,
|
37
|
+
args: args.to_json,
|
38
|
+
contract_address: contract_address
|
39
|
+
}
|
36
40
|
|
41
|
+
req[:abi] = abi.to_json unless abi.nil?
|
42
|
+
|
43
|
+
# For payable contract invocations, convert the amount to atomic units of specified asset.
|
37
44
|
if amount && asset_id && network
|
38
|
-
|
39
|
-
|
40
|
-
|
45
|
+
asset = Coinbase::Asset.fetch(network, asset_id)
|
46
|
+
|
47
|
+
req[:amount] = asset.to_atomic_amount(amount).to_i.to_s
|
41
48
|
end
|
42
49
|
|
43
50
|
model = Coinbase.call_api do
|
44
|
-
contract_invocation_api.create_contract_invocation(
|
45
|
-
wallet_id,
|
46
|
-
address_id,
|
47
|
-
contract_address: contract_address,
|
48
|
-
abi: abi.to_json,
|
49
|
-
method: method,
|
50
|
-
args: args.to_json,
|
51
|
-
amount: atomic_amount
|
52
|
-
)
|
51
|
+
contract_invocation_api.create_contract_invocation(wallet_id, address_id, **req)
|
53
52
|
end
|
54
53
|
|
55
54
|
new(model)
|
@@ -23,63 +23,64 @@ module Coinbase
|
|
23
23
|
)
|
24
24
|
Coinbase::Pagination.enumerate(
|
25
25
|
lambda { |page|
|
26
|
-
list_events_page(
|
27
|
-
|
26
|
+
list_events_page(
|
27
|
+
network_id,
|
28
|
+
protocol_name,
|
29
|
+
contract_address,
|
30
|
+
contract_name,
|
31
|
+
event_name,
|
32
|
+
from_block_height,
|
33
|
+
to_block_height,
|
34
|
+
page
|
35
|
+
)
|
28
36
|
}
|
29
37
|
) do |contract_event|
|
30
38
|
Coinbase::ContractEvent.new(contract_event)
|
31
39
|
end
|
32
40
|
end
|
33
41
|
|
34
|
-
#
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
# @return [
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
# Returns a string representation of the SmartContract.
|
65
|
-
# @return [String] a string representation of the SmartContract
|
66
|
-
def to_s
|
67
|
-
"Coinbase::SmartContract{
|
68
|
-
network_id: '#{network_id}',
|
69
|
-
protocol_name: '#{protocol_name}',
|
70
|
-
contract_name: '#{contract_name}',
|
71
|
-
address: '#{address}'}"
|
72
|
-
end
|
42
|
+
# Creates a new ERC20 token contract, that can subsequently be deployed to
|
43
|
+
# the blockchain.
|
44
|
+
# @param address_id [String] The address ID of deployer
|
45
|
+
# @param wallet_id [String] The wallet ID of the deployer
|
46
|
+
# @param name [String] The name of the token
|
47
|
+
# @param symbol [String] The symbol of the token
|
48
|
+
# @param total_supply [String] The total supply of the token, denominate in whole units.
|
49
|
+
# @return [SmartContract] The new ERC20 Token SmartContract object
|
50
|
+
def self.create_token_contract(
|
51
|
+
address_id:,
|
52
|
+
wallet_id:,
|
53
|
+
name:,
|
54
|
+
symbol:,
|
55
|
+
total_supply:
|
56
|
+
)
|
57
|
+
contract = Coinbase.call_api do
|
58
|
+
smart_contracts_api.create_smart_contract(
|
59
|
+
wallet_id,
|
60
|
+
address_id,
|
61
|
+
{
|
62
|
+
type: Coinbase::Client::SmartContractType::ERC20,
|
63
|
+
options: Coinbase::Client::TokenContractOptions.new(
|
64
|
+
name: name,
|
65
|
+
symbol: symbol,
|
66
|
+
total_supply: BigDecimal(total_supply).to_i.to_s
|
67
|
+
).to_body
|
68
|
+
}
|
69
|
+
)
|
70
|
+
end
|
73
71
|
|
74
|
-
|
75
|
-
# @return [String] a string representation of the SmartContract
|
76
|
-
def inspect
|
77
|
-
to_s
|
72
|
+
new(contract)
|
78
73
|
end
|
79
74
|
|
80
75
|
def self.contract_events_api
|
81
76
|
Coinbase::Client::ContractEventsApi.new(Coinbase.configuration.api_client)
|
82
77
|
end
|
78
|
+
private_class_method :contract_events_api
|
79
|
+
|
80
|
+
def self.smart_contracts_api
|
81
|
+
Coinbase::Client::SmartContractsApi.new(Coinbase.configuration.api_client)
|
82
|
+
end
|
83
|
+
private_class_method :smart_contracts_api
|
83
84
|
|
84
85
|
def self.list_events_page(
|
85
86
|
network_id,
|
@@ -102,5 +103,175 @@ module Coinbase
|
|
102
103
|
{ next_page: page }
|
103
104
|
)
|
104
105
|
end
|
106
|
+
private_class_method :list_events_page
|
107
|
+
|
108
|
+
# Returns a new SmartContract object.
|
109
|
+
# @param model [Coinbase::Client::SmartContract] The underlying SmartContract object
|
110
|
+
def initialize(model)
|
111
|
+
raise unless model.is_a?(Coinbase::Client::SmartContract)
|
112
|
+
|
113
|
+
@model = model
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns the SmartContract ID.
|
117
|
+
# NOTE: This is not the contract address and is primarily used before
|
118
|
+
# the contract is deployed.
|
119
|
+
# @return [String] The SmartContract ID
|
120
|
+
def id
|
121
|
+
@model.smart_contract_id
|
122
|
+
end
|
123
|
+
|
124
|
+
# Returns the Network of the SmartContract.
|
125
|
+
# @return [Coinbase::Network] The Network
|
126
|
+
def network
|
127
|
+
@network ||= Coinbase::Network.from_id(@model.network_id)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Returns the contract address of the SmartContract.
|
131
|
+
# @return [String] The contract address
|
132
|
+
def contract_address
|
133
|
+
@model.contract_address
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns the address of the deployer of the SmartContract.
|
137
|
+
# @return [String] The deployer address
|
138
|
+
def deployer_address
|
139
|
+
@model.deployer_address
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns the ABI of the Smart Contract.
|
143
|
+
# @return [Array<Hash>] The ABI
|
144
|
+
def abi
|
145
|
+
JSON.parse(@model.abi)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Returns the ID of the wallet that deployed the SmartContract.
|
149
|
+
# @return [String] The wallet ID
|
150
|
+
def wallet_id
|
151
|
+
@model.wallet_id
|
152
|
+
end
|
153
|
+
|
154
|
+
# Returns the type of the SmartContract.
|
155
|
+
# @return [Coinbase::Client::SmartContractType] The SmartContract type
|
156
|
+
def type
|
157
|
+
@model.type
|
158
|
+
end
|
159
|
+
|
160
|
+
# Returns the options of the SmartContract.
|
161
|
+
# @return [Coinbase::Client::SmartContractOptions] The SmartContract options
|
162
|
+
def options
|
163
|
+
@model.options
|
164
|
+
end
|
165
|
+
|
166
|
+
# Returns the transaction.
|
167
|
+
# @return [Coinbase::Transaction] The SmartContracy deployment transaction
|
168
|
+
def transaction
|
169
|
+
@transaction ||= Coinbase::Transaction.new(@model.transaction)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns the status of the SmartContract.
|
173
|
+
# @return [String] The status
|
174
|
+
def status
|
175
|
+
transaction.status
|
176
|
+
end
|
177
|
+
|
178
|
+
# Signs the SmartContract deployment transaction with the given key.
|
179
|
+
# This is required before broadcasting the SmartContract.
|
180
|
+
# @param key [Eth::Key] The key to sign the SmartContract with
|
181
|
+
# @return [SmartContract] The SmartContract object
|
182
|
+
# @raise [RuntimeError] If the key is not an Eth::Key
|
183
|
+
# @raise [Coinbase::AlreadySignedError] If the SmartContract has already been signed
|
184
|
+
def sign(key)
|
185
|
+
raise unless key.is_a?(Eth::Key)
|
186
|
+
|
187
|
+
transaction.sign(key)
|
188
|
+
end
|
189
|
+
|
190
|
+
# Deploys the signed SmartContract to the blockchain.
|
191
|
+
# @return [SmartContract] The SmartContract object
|
192
|
+
# @raise [Coinbase::TransactionNotSignedError] If the SmartContract has not been signed
|
193
|
+
def deploy!
|
194
|
+
raise TransactionNotSignedError unless transaction.signed?
|
195
|
+
|
196
|
+
@model = Coinbase.call_api do
|
197
|
+
smart_contracts_api.deploy_smart_contract(
|
198
|
+
wallet_id,
|
199
|
+
deployer_address,
|
200
|
+
id,
|
201
|
+
{ signed_payload: transaction.signature }
|
202
|
+
)
|
203
|
+
end
|
204
|
+
|
205
|
+
@transaction = Coinbase::Transaction.new(@model.transaction)
|
206
|
+
|
207
|
+
self
|
208
|
+
end
|
209
|
+
|
210
|
+
# Reloads the Smart Contract model with the latest version from the server side.
|
211
|
+
# @return [SmartContract] The most recent version of Smart Contract from the server
|
212
|
+
def reload
|
213
|
+
@model = Coinbase.call_api do
|
214
|
+
smart_contracts_api.get_smart_contract(
|
215
|
+
wallet_id,
|
216
|
+
deployer_address,
|
217
|
+
id
|
218
|
+
)
|
219
|
+
end
|
220
|
+
|
221
|
+
@transaction = Coinbase::Transaction.new(@model.transaction)
|
222
|
+
|
223
|
+
self
|
224
|
+
end
|
225
|
+
|
226
|
+
# Waits until the Smart Contract deployment is signed or failed by polling the server at the given interval.
|
227
|
+
# @param interval_seconds [Integer] The interval at which to poll the server, in seconds
|
228
|
+
# @param timeout_seconds [Integer] The maximum amount of time to wait for the Smart Contract,
|
229
|
+
# deployment to land on-chain, in seconds
|
230
|
+
# @return [SmartContract] The completed Smart Contract object
|
231
|
+
# @raise [Timeout::Error] if the Contract Invocation takes longer than the given timeout
|
232
|
+
def wait!(interval_seconds = 0.2, timeout_seconds = 20)
|
233
|
+
start_time = Time.now
|
234
|
+
|
235
|
+
loop do
|
236
|
+
reload
|
237
|
+
|
238
|
+
return self if transaction.terminal_state?
|
239
|
+
|
240
|
+
if Time.now - start_time > timeout_seconds
|
241
|
+
raise Timeout::Error,
|
242
|
+
'SmartContract deployment timed out. Try waiting again.'
|
243
|
+
end
|
244
|
+
|
245
|
+
self.sleep interval_seconds
|
246
|
+
end
|
247
|
+
|
248
|
+
self
|
249
|
+
end
|
250
|
+
|
251
|
+
# Same as to_s.
|
252
|
+
# @return [String] a string representation of the SmartContract
|
253
|
+
def inspect
|
254
|
+
to_s
|
255
|
+
end
|
256
|
+
|
257
|
+
# Returns a string representation of the SmartContract.
|
258
|
+
# @return [String] a string representation of the SmartContract
|
259
|
+
def to_s
|
260
|
+
Coinbase.pretty_print_object(
|
261
|
+
self.class,
|
262
|
+
network: network.id,
|
263
|
+
contract_address: contract_address,
|
264
|
+
deployer_address: deployer_address,
|
265
|
+
type: type,
|
266
|
+
status: status,
|
267
|
+
options: Coinbase.pretty_print_object('Options', **options)
|
268
|
+
)
|
269
|
+
end
|
270
|
+
|
271
|
+
private
|
272
|
+
|
273
|
+
def smart_contracts_api
|
274
|
+
@smart_contracts_api ||= Coinbase::Client::SmartContractsApi.new(Coinbase.configuration.api_client)
|
275
|
+
end
|
105
276
|
end
|
106
277
|
end
|
data/lib/coinbase/transaction.rb
CHANGED
@@ -147,6 +147,9 @@ module Coinbase
|
|
147
147
|
# Signs the Transaction with the provided key and returns the hex signing payload.
|
148
148
|
# @return [String] The hex-encoded signed payload
|
149
149
|
def sign(key)
|
150
|
+
raise 'Invalid key type' unless key.is_a?(Eth::Key)
|
151
|
+
raise Coinbase::AlreadySignedError if signed?
|
152
|
+
|
150
153
|
raw.sign(key)
|
151
154
|
|
152
155
|
signature
|
data/lib/coinbase/transfer.rb
CHANGED
data/lib/coinbase/version.rb
CHANGED
data/lib/coinbase/wallet.rb
CHANGED
@@ -234,10 +234,19 @@ module Coinbase
|
|
234
234
|
# @!method invoke_contract
|
235
235
|
# Invokes a contract with the given ABI, method, and arguments.
|
236
236
|
# @param abi [Array<Hash>] The ABI of the contract
|
237
|
-
|
237
|
+
|
238
|
+
# @!method deploy_token
|
239
|
+
# Deploys a new ERC20 token contract with the given name, symbol, and total supply.
|
240
|
+
# @param name [String] The name of the token.
|
241
|
+
# @param symbol [String] The symbol of the token.
|
242
|
+
# @param total_supply [Integer, BigDecimal] The total supply of the token, denominated in
|
243
|
+
# whole units.
|
244
|
+
# @return [Coinbase::SmartContract] The deployed token contract.
|
245
|
+
# @raise [AddressCannotSignError] if the Address does not have a private key backing it.
|
238
246
|
|
239
247
|
def_delegators :default_address, :transfer, :trade, :faucet, :stake, :unstake, :claim_stake, :staking_balances,
|
240
|
-
:stakeable_balance, :unstakeable_balance, :claimable_balance, :sign_payload, :invoke_contract
|
248
|
+
:stakeable_balance, :unstakeable_balance, :claimable_balance, :sign_payload, :invoke_contract,
|
249
|
+
:deploy_token
|
241
250
|
|
242
251
|
# Returns the addresses belonging to the Wallet.
|
243
252
|
# @return [Array<Coinbase::WalletAddress>] The addresses belonging to the Wallet
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coinbase-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuga Cohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|
@@ -285,9 +285,11 @@ files:
|
|
285
285
|
- lib/coinbase/client/api/external_addresses_api.rb
|
286
286
|
- lib/coinbase/client/api/networks_api.rb
|
287
287
|
- lib/coinbase/client/api/server_signers_api.rb
|
288
|
+
- lib/coinbase/client/api/smart_contracts_api.rb
|
288
289
|
- lib/coinbase/client/api/stake_api.rb
|
289
290
|
- lib/coinbase/client/api/trades_api.rb
|
290
291
|
- lib/coinbase/client/api/transfers_api.rb
|
292
|
+
- lib/coinbase/client/api/users_api.rb
|
291
293
|
- lib/coinbase/client/api/validators_api.rb
|
292
294
|
- lib/coinbase/client/api/wallet_stake_api.rb
|
293
295
|
- lib/coinbase/client/api/wallets_api.rb
|
@@ -315,12 +317,14 @@ files:
|
|
315
317
|
- lib/coinbase/client/models/create_contract_invocation_request.rb
|
316
318
|
- lib/coinbase/client/models/create_payload_signature_request.rb
|
317
319
|
- lib/coinbase/client/models/create_server_signer_request.rb
|
320
|
+
- lib/coinbase/client/models/create_smart_contract_request.rb
|
318
321
|
- lib/coinbase/client/models/create_staking_operation_request.rb
|
319
322
|
- lib/coinbase/client/models/create_trade_request.rb
|
320
323
|
- lib/coinbase/client/models/create_transfer_request.rb
|
321
324
|
- lib/coinbase/client/models/create_wallet_request.rb
|
322
325
|
- lib/coinbase/client/models/create_wallet_request_wallet.rb
|
323
326
|
- lib/coinbase/client/models/create_webhook_request.rb
|
327
|
+
- lib/coinbase/client/models/deploy_smart_contract_request.rb
|
324
328
|
- lib/coinbase/client/models/erc20_transfer_event.rb
|
325
329
|
- lib/coinbase/client/models/erc721_transfer_event.rb
|
326
330
|
- lib/coinbase/client/models/error.rb
|
@@ -330,6 +334,7 @@ files:
|
|
330
334
|
- lib/coinbase/client/models/ethereum_transaction_flattened_trace.rb
|
331
335
|
- lib/coinbase/client/models/ethereum_validator_metadata.rb
|
332
336
|
- lib/coinbase/client/models/faucet_transaction.rb
|
337
|
+
- lib/coinbase/client/models/feature.rb
|
333
338
|
- lib/coinbase/client/models/feature_set.rb
|
334
339
|
- lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb
|
335
340
|
- lib/coinbase/client/models/fetch_staking_rewards200_response.rb
|
@@ -338,6 +343,7 @@ files:
|
|
338
343
|
- lib/coinbase/client/models/historical_balance.rb
|
339
344
|
- lib/coinbase/client/models/network.rb
|
340
345
|
- lib/coinbase/client/models/network_identifier.rb
|
346
|
+
- lib/coinbase/client/models/nft_contract_options.rb
|
341
347
|
- lib/coinbase/client/models/payload_signature.rb
|
342
348
|
- lib/coinbase/client/models/payload_signature_list.rb
|
343
349
|
- lib/coinbase/client/models/seed_creation_event.rb
|
@@ -350,6 +356,10 @@ files:
|
|
350
356
|
- lib/coinbase/client/models/signature_creation_event.rb
|
351
357
|
- lib/coinbase/client/models/signature_creation_event_result.rb
|
352
358
|
- lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb
|
359
|
+
- lib/coinbase/client/models/smart_contract.rb
|
360
|
+
- lib/coinbase/client/models/smart_contract_list.rb
|
361
|
+
- lib/coinbase/client/models/smart_contract_options.rb
|
362
|
+
- lib/coinbase/client/models/smart_contract_type.rb
|
353
363
|
- lib/coinbase/client/models/sponsored_send.rb
|
354
364
|
- lib/coinbase/client/models/staking_balance.rb
|
355
365
|
- lib/coinbase/client/models/staking_context.rb
|
@@ -359,6 +369,7 @@ files:
|
|
359
369
|
- lib/coinbase/client/models/staking_reward.rb
|
360
370
|
- lib/coinbase/client/models/staking_reward_format.rb
|
361
371
|
- lib/coinbase/client/models/staking_reward_usd_value.rb
|
372
|
+
- lib/coinbase/client/models/token_contract_options.rb
|
362
373
|
- lib/coinbase/client/models/trade.rb
|
363
374
|
- lib/coinbase/client/models/trade_list.rb
|
364
375
|
- lib/coinbase/client/models/transaction.rb
|
@@ -367,6 +378,7 @@ files:
|
|
367
378
|
- lib/coinbase/client/models/transfer.rb
|
368
379
|
- lib/coinbase/client/models/transfer_list.rb
|
369
380
|
- lib/coinbase/client/models/update_webhook_request.rb
|
381
|
+
- lib/coinbase/client/models/user.rb
|
370
382
|
- lib/coinbase/client/models/validator.rb
|
371
383
|
- lib/coinbase/client/models/validator_details.rb
|
372
384
|
- lib/coinbase/client/models/validator_list.rb
|
@@ -376,7 +388,9 @@ files:
|
|
376
388
|
- lib/coinbase/client/models/webhook.rb
|
377
389
|
- lib/coinbase/client/models/webhook_event_filter.rb
|
378
390
|
- lib/coinbase/client/models/webhook_event_type.rb
|
391
|
+
- lib/coinbase/client/models/webhook_event_type_filter.rb
|
379
392
|
- lib/coinbase/client/models/webhook_list.rb
|
393
|
+
- lib/coinbase/client/models/webhook_wallet_activity_filter.rb
|
380
394
|
- lib/coinbase/client/version.rb
|
381
395
|
- lib/coinbase/constants.rb
|
382
396
|
- lib/coinbase/contract_event.rb
|