coinbase-sdk 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coinbase/address/wallet_address.rb +7 -4
- data/lib/coinbase/address.rb +15 -9
- data/lib/coinbase/client/api/addresses_api.rb +3 -0
- data/lib/coinbase/client/api/external_addresses_api.rb +4 -1
- data/lib/coinbase/staking_operation.rb +27 -3
- data/lib/coinbase/version.rb +1 -1
- data/lib/coinbase/wallet.rb +1 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb99df68459ac0ded3425479c79a09a0eb0aba9a9eb213939254b049e582f6d3
|
4
|
+
data.tar.gz: c4bb9230a726749208267afae1ce4af39c198e619273c4c38c44fa08f3729e60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41190c14711f7f1ce56ce668b60fc0e0319a9d1aa0b382f46242db330961a3bfda950ab4e619eb9202595ce172111da8eb3bcd4cb133ac030ca0bf2e4d7d6247
|
7
|
+
data.tar.gz: a471b10bff8d80dda05183b855967907357c5f84feabc0ee40ed37b6ca081d4c6bb75d72e91a6edc8ca67fadcc3d30437db67ee16c557b89c22291f02bab01e0
|
@@ -95,11 +95,12 @@ module Coinbase
|
|
95
95
|
trade
|
96
96
|
end
|
97
97
|
|
98
|
-
# Stakes the given amount of the given Asset
|
98
|
+
# Stakes the given amount of the given Asset. The stake operation
|
99
|
+
# may take a few minutes to complete in the case when infrastructure is spun up.
|
99
100
|
# @param amount [Integer, Float, BigDecimal] The amount of the Asset to stake.
|
100
101
|
# @param asset_id [Symbol] The ID of the Asset to stake. For Ether, :eth, :gwei, and :wei are supported.
|
101
102
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
102
|
-
# @param options [Hash] Additional options for the stake operation
|
103
|
+
# @param options [Hash] (Optional) Additional options for the stake operation. ({StakingOperation#create see_more})
|
103
104
|
# @param interval_seconds [Integer] The number of seconds to wait between polling for updates. Defaults to 5.
|
104
105
|
# @param timeout_seconds [Integer] The number of seconds to wait before timing out. Defaults to 600.
|
105
106
|
# @return [Coinbase::StakingOperation] The staking operation
|
@@ -116,7 +117,8 @@ module Coinbase
|
|
116
117
|
# @param amount [Integer, Float, BigDecimal] The amount of the Asset to unstake.
|
117
118
|
# @param asset_id [Symbol] The ID of the Asset to stake. For Ether, :eth, :gwei, and :wei are supported.
|
118
119
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
119
|
-
# @param options [Hash] Additional options for the
|
120
|
+
# @param options [Hash] (Optional) Additional options for the unstake operation.
|
121
|
+
# ({StakingOperation#create see_more})
|
120
122
|
# @param interval_seconds [Integer] The number of seconds to wait between polling for updates. Defaults to 5.
|
121
123
|
# @param timeout_seconds [Integer] The number of seconds to wait before timing out. Defaults to 600.
|
122
124
|
# @return [Coinbase::StakingOperation] The staking operation
|
@@ -133,7 +135,8 @@ module Coinbase
|
|
133
135
|
# @param amount [Integer, Float, BigDecimal] The amount of the Asset to claim.
|
134
136
|
# @param asset_id [Symbol] The ID of the Asset to stake. For Ether, :eth, :gwei, and :wei are supported.
|
135
137
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
136
|
-
# @param options [Hash] Additional options for the
|
138
|
+
# @param options [Hash] (Optional) Additional options for the claim_stake operation.
|
139
|
+
# ({StakingOperation#create see_more})
|
137
140
|
# @param interval_seconds [Integer] The number of seconds to wait between polling for updates. Defaults to 5.
|
138
141
|
# @param timeout_seconds [Integer] The number of seconds to wait before timing out. Defaults to 600.
|
139
142
|
# @return [Coinbase::StakingOperation] The staking operation
|
data/lib/coinbase/address.rb
CHANGED
@@ -74,13 +74,16 @@ module Coinbase
|
|
74
74
|
|
75
75
|
# Requests funds for the address from the faucet and returns the faucet transaction.
|
76
76
|
# This is only supported on testnet networks.
|
77
|
+
# @param asset_id [Symbol] The ID of the Asset to transfer to the wallet.
|
77
78
|
# @return [Coinbase::FaucetTransaction] The successful faucet transaction
|
78
79
|
# @raise [Coinbase::FaucetLimitReachedError] If the faucet limit has been reached for the address or user.
|
79
80
|
# @raise [Coinbase::Client::ApiError] If an unexpected error occurs while requesting faucet funds.
|
80
|
-
def faucet
|
81
|
+
def faucet(asset_id: nil)
|
82
|
+
opts = { asset_id: asset_id }.compact
|
83
|
+
|
81
84
|
Coinbase.call_api do
|
82
85
|
Coinbase::FaucetTransaction.new(
|
83
|
-
addresses_api.request_external_faucet_funds(network.normalized_id, id)
|
86
|
+
addresses_api.request_external_faucet_funds(network.normalized_id, id, opts)
|
84
87
|
)
|
85
88
|
end
|
86
89
|
end
|
@@ -90,7 +93,7 @@ module Coinbase
|
|
90
93
|
# @param amount [Integer,String,BigDecimal] The amount of the asset to stake
|
91
94
|
# @param asset_id [Symbol] The asset to stake
|
92
95
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
93
|
-
# @param options [Hash] Additional options for the stake operation
|
96
|
+
# @param options [Hash] (Optional) Additional options for the stake operation. ({StakingOperation#build see_more})
|
94
97
|
# @return [Coinbase::StakingOperation] The stake operation
|
95
98
|
def build_stake_operation(amount, asset_id, mode: :default, options: {})
|
96
99
|
validate_can_perform_staking_action!(amount, asset_id, 'stakeable_balance', mode, options)
|
@@ -102,7 +105,7 @@ module Coinbase
|
|
102
105
|
# @param amount [Integer,String,BigDecimal] The amount of the asset to unstake
|
103
106
|
# @param asset_id [Symbol] The asset to unstake
|
104
107
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
105
|
-
# @param options [Hash] Additional options for the unstake operation
|
108
|
+
# @param options [Hash] (Optional) Additional options for the unstake operation. ({StakingOperation#build see_more})
|
106
109
|
# @return [Coinbase::StakingOperation] The unstake operation
|
107
110
|
def build_unstake_operation(amount, asset_id, mode: :default, options: {})
|
108
111
|
validate_can_perform_staking_action!(amount, asset_id, 'unstakeable_balance', mode, options)
|
@@ -114,7 +117,8 @@ module Coinbase
|
|
114
117
|
# @param amount [Integer,String,BigDecimal] The amount of the asset to claim
|
115
118
|
# @param asset_id [Symbol] The asset to claim
|
116
119
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
117
|
-
# @param options [Hash] Additional options for the claim_stake operation
|
120
|
+
# @param options [Hash] (Optional) Additional options for the claim_stake operation.
|
121
|
+
# ({StakingOperation#build see_more})
|
118
122
|
# @return [Coinbase::StakingOperation] The claim_stake operation
|
119
123
|
def build_claim_stake_operation(amount, asset_id, mode: :default, options: {})
|
120
124
|
validate_can_perform_staking_action!(amount, asset_id, 'claimable_balance', mode, options)
|
@@ -125,7 +129,9 @@ module Coinbase
|
|
125
129
|
# Retrieves the balances used for staking for the supplied asset.
|
126
130
|
# @param asset_id [Symbol] The asset to retrieve staking balances for
|
127
131
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
128
|
-
# @param options [Hash] Additional options for the staking
|
132
|
+
# @param options [Hash] (Optional) Additional options for fetching the staking balances
|
133
|
+
# @option options [String] (Optional) :validator_pub_keys List of comma separated validator public keys to retrieve
|
134
|
+
# staking balances for. (default: all validators) [asset_id: :eth, mode: :native]
|
129
135
|
# @return [Hash] The staking balances
|
130
136
|
# @return [BigDecimal] :stakeable_balance The amount of the asset that can be staked
|
131
137
|
# @return [BigDecimal] :unstakeable_balance The amount of the asset that is currently staked and cannot be unstaked
|
@@ -163,7 +169,7 @@ module Coinbase
|
|
163
169
|
# Retrieves the stakeable balance for the supplied asset.
|
164
170
|
# @param asset_id [Symbol] The asset to retrieve the stakeable balance for
|
165
171
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
166
|
-
# @param options [Hash] Additional options for the
|
172
|
+
# @param options [Hash] Additional options for fetching the stakeable balance
|
167
173
|
# @return [BigDecimal] The stakeable balance
|
168
174
|
def stakeable_balance(asset_id, mode: :default, options: {})
|
169
175
|
staking_balances(asset_id, mode: mode, options: options)[:stakeable_balance]
|
@@ -172,7 +178,7 @@ module Coinbase
|
|
172
178
|
# Retrieves the unstakeable balance for the supplied asset.
|
173
179
|
# @param asset_id [Symbol] The asset to retrieve the unstakeable balance for
|
174
180
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
175
|
-
# @param options [Hash] Additional options for the
|
181
|
+
# @param options [Hash] Additional options for fetching the unstakeable balance
|
176
182
|
# @return [BigDecimal] The unstakeable balance
|
177
183
|
def unstakeable_balance(asset_id, mode: :default, options: {})
|
178
184
|
staking_balances(asset_id, mode: mode, options: options)[:unstakeable_balance]
|
@@ -181,7 +187,7 @@ module Coinbase
|
|
181
187
|
# Retrieves the claimable balance for the supplied asset.
|
182
188
|
# @param asset_id [Symbol] The asset to retrieve the claimable balance for
|
183
189
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
184
|
-
# @param options [Hash] Additional options for the
|
190
|
+
# @param options [Hash] Additional options for fetching the claimable balance
|
185
191
|
# @return [BigDecimal] The claimable balance
|
186
192
|
def claimable_balance(asset_id, mode: :default, options: {})
|
187
193
|
staking_balances(asset_id, mode: mode, options: options)[:claimable_balance]
|
@@ -387,6 +387,7 @@ module Coinbase::Client
|
|
387
387
|
# @param wallet_id [String] The ID of the wallet the address belongs to.
|
388
388
|
# @param address_id [String] The onchain address of the address that is being fetched.
|
389
389
|
# @param [Hash] opts the optional parameters
|
390
|
+
# @option opts [String] :asset_id The ID of the asset to transfer from the faucet.
|
390
391
|
# @return [FaucetTransaction]
|
391
392
|
def request_faucet_funds(wallet_id, address_id, opts = {})
|
392
393
|
data, _status_code, _headers = request_faucet_funds_with_http_info(wallet_id, address_id, opts)
|
@@ -398,6 +399,7 @@ module Coinbase::Client
|
|
398
399
|
# @param wallet_id [String] The ID of the wallet the address belongs to.
|
399
400
|
# @param address_id [String] The onchain address of the address that is being fetched.
|
400
401
|
# @param [Hash] opts the optional parameters
|
402
|
+
# @option opts [String] :asset_id The ID of the asset to transfer from the faucet.
|
401
403
|
# @return [Array<(FaucetTransaction, Integer, Hash)>] FaucetTransaction data, response status code and response headers
|
402
404
|
def request_faucet_funds_with_http_info(wallet_id, address_id, opts = {})
|
403
405
|
if @api_client.config.debugging
|
@@ -416,6 +418,7 @@ module Coinbase::Client
|
|
416
418
|
|
417
419
|
# query parameters
|
418
420
|
query_params = opts[:query_params] || {}
|
421
|
+
query_params[:'asset_id'] = opts[:'asset_id'] if !opts[:'asset_id'].nil?
|
419
422
|
|
420
423
|
# header parameters
|
421
424
|
header_params = opts[:header_params] || {}
|
@@ -224,7 +224,7 @@ module Coinbase::Client
|
|
224
224
|
# header parameters
|
225
225
|
header_params = opts[:header_params] || {}
|
226
226
|
# HTTP header 'Accept' (if needed)
|
227
|
-
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
227
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
228
228
|
|
229
229
|
# form parameters
|
230
230
|
form_params = opts[:form_params] || {}
|
@@ -260,6 +260,7 @@ module Coinbase::Client
|
|
260
260
|
# @param network_id [String] The ID of the wallet the address belongs to.
|
261
261
|
# @param address_id [String] The onchain address of the address that is being fetched.
|
262
262
|
# @param [Hash] opts the optional parameters
|
263
|
+
# @option opts [String] :asset_id The ID of the asset to transfer from the faucet.
|
263
264
|
# @return [FaucetTransaction]
|
264
265
|
def request_external_faucet_funds(network_id, address_id, opts = {})
|
265
266
|
data, _status_code, _headers = request_external_faucet_funds_with_http_info(network_id, address_id, opts)
|
@@ -271,6 +272,7 @@ module Coinbase::Client
|
|
271
272
|
# @param network_id [String] The ID of the wallet the address belongs to.
|
272
273
|
# @param address_id [String] The onchain address of the address that is being fetched.
|
273
274
|
# @param [Hash] opts the optional parameters
|
275
|
+
# @option opts [String] :asset_id The ID of the asset to transfer from the faucet.
|
274
276
|
# @return [Array<(FaucetTransaction, Integer, Hash)>] FaucetTransaction data, response status code and response headers
|
275
277
|
def request_external_faucet_funds_with_http_info(network_id, address_id, opts = {})
|
276
278
|
if @api_client.config.debugging
|
@@ -289,6 +291,7 @@ module Coinbase::Client
|
|
289
291
|
|
290
292
|
# query parameters
|
291
293
|
query_params = opts[:query_params] || {}
|
294
|
+
query_params[:'asset_id'] = opts[:'asset_id'] if !opts[:'asset_id'].nil?
|
292
295
|
|
293
296
|
# header parameters
|
294
297
|
header_params = opts[:header_params] || {}
|
@@ -17,6 +17,19 @@ module Coinbase
|
|
17
17
|
# @param action [Symbol] The action to perform
|
18
18
|
# @param mode [Symbol] The staking mode
|
19
19
|
# @param options [Hash] Additional options
|
20
|
+
# @option options [String] :integrator_contract_address The integrator contract
|
21
|
+
# address. [asset_id: :eth, mode: :partial, action: all]
|
22
|
+
# @option options [String] :funding_address The address funding the 32 ETH
|
23
|
+
# (default: :address_id) [asset_id: :eth, mode: :native, action: :stake]
|
24
|
+
# @option options [String] :withdrawal_address The address receiving rewards and withdrawal funds.
|
25
|
+
# (default: :address_id) [asset_id: :eth, mode: :native, action: :stake]
|
26
|
+
# @option options [String] :fee_recipient_address The address receiving transaction fees.
|
27
|
+
# (default: :address_id) [asset_id: :eth, mode: :native, action: :stake]
|
28
|
+
# @option options [Boolean] :immediate To leverage "Coinbase Managed Unstake".
|
29
|
+
# (default: false i.e. User Managed Unstake) [asset_id: :eth, mode: :native, action: :unstake]
|
30
|
+
# @option options [String] :validator_pub_keys List of comma separated validator public keys to unstake.
|
31
|
+
# (default: validators picked up on your behalf corresponding to the unstake amount.) [asset_id: :eth,
|
32
|
+
# mode: :native, action: :unstake]
|
20
33
|
# @return [Coinbase::StakingOperation] The staking operation
|
21
34
|
def self.build(amount, network, asset_id, address_id, action, mode, options)
|
22
35
|
network = Coinbase::Network.from_id(network)
|
@@ -49,6 +62,19 @@ module Coinbase
|
|
49
62
|
# @param action [Symbol] The action to perform
|
50
63
|
# @param mode [Symbol] The staking mode
|
51
64
|
# @param options [Hash] Additional options
|
65
|
+
# @option options [String] :integrator_contract_address The integrator contract
|
66
|
+
# address. [asset_id: :eth, mode: :partial, action: all]
|
67
|
+
# @option options [String] :funding_address The address funding the 32 ETH
|
68
|
+
# (default: :address_id) [asset_id: :eth, mode: :native, action: :stake]
|
69
|
+
# @option options [String] :withdrawal_address The address receiving rewards and withdrawal funds.
|
70
|
+
# (default: :address_id) [asset_id: :eth, mode: :native, action: :stake]
|
71
|
+
# @option options [String] :fee_recipient_address The address receiving transaction fees.
|
72
|
+
# (default: :address_id) [asset_id: :eth, mode: :native, action: :stake]
|
73
|
+
# @option options [Boolean] :immediate To leverage "Coinbase Managed Unstake".
|
74
|
+
# (default: false i.e. User Managed Unstake) [asset_id: :eth, mode: :native, action: :unstake]
|
75
|
+
# @option options [String] :validator_pub_keys List of comma separated validator public keys to unstake.
|
76
|
+
# (default: validators picked up on your behalf corresponding to the unstake amount.) [asset_id: :eth,
|
77
|
+
# mode: :native, action: :unstake]
|
52
78
|
# @return [Coinbase::StakingOperation] The staking operation
|
53
79
|
def self.create(amount, network, asset_id, address_id, wallet_id, action, mode, options)
|
54
80
|
network = Coinbase::Network.from_id(network)
|
@@ -194,7 +220,7 @@ module Coinbase
|
|
194
220
|
|
195
221
|
transaction.sign(key)
|
196
222
|
@model = Coinbase.call_api do
|
197
|
-
|
223
|
+
wallet_stake_api.broadcast_staking_operation(
|
198
224
|
wallet_id,
|
199
225
|
address_id,
|
200
226
|
id,
|
@@ -211,8 +237,6 @@ module Coinbase
|
|
211
237
|
|
212
238
|
sleep interval_seconds
|
213
239
|
end
|
214
|
-
|
215
|
-
self
|
216
240
|
end
|
217
241
|
|
218
242
|
# Fetch the StakingOperation with the provided network, address and staking operation ID.
|
data/lib/coinbase/version.rb
CHANGED
data/lib/coinbase/wallet.rb
CHANGED
@@ -162,6 +162,7 @@ module Coinbase
|
|
162
162
|
# @return [Coinbase::Trade] The Trade object.
|
163
163
|
|
164
164
|
# @!method faucet
|
165
|
+
# @param asset_id [Symbol] The ID of the Asset to transfer to the wallet.
|
165
166
|
# Requests funds from the faucet for the Wallet's default address and returns the faucet transaction.
|
166
167
|
# This is only supported on testnet networks.
|
167
168
|
# @return [Coinbase::FaucetTransaction] The successful faucet transaction
|
@@ -363,12 +364,6 @@ module Coinbase
|
|
363
364
|
Data.new(wallet_id: id, seed: @master.seed_hex)
|
364
365
|
end
|
365
366
|
|
366
|
-
def faucet
|
367
|
-
Coinbase.call_api do
|
368
|
-
Coinbase::FaucetTransaction.new(addresses_api.request_faucet_funds(id, default_address.id))
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
367
|
# Returns whether the Wallet has a seed with which to derive keys and sign transactions.
|
373
368
|
# @return [Boolean] Whether the Wallet has a seed with which to derive keys and sign transactions.
|
374
369
|
def can_sign?
|
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.2.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-08-
|
11
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|