coinbase-sdk 0.0.7 → 0.0.9
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/external_address.rb +173 -0
- data/lib/coinbase/address/wallet_address.rb +219 -0
- data/lib/coinbase/address.rb +32 -219
- data/lib/coinbase/asset.rb +76 -66
- data/lib/coinbase/authenticator.rb +2 -0
- data/lib/coinbase/balance.rb +10 -6
- data/lib/coinbase/client/api/addresses_api.rb +1 -1
- data/lib/coinbase/client/api/assets_api.rb +91 -0
- data/lib/coinbase/client/api/external_addresses_api.rb +242 -0
- data/lib/coinbase/client/api/server_signers_api.rb +1 -1
- data/lib/coinbase/client/api/stake_api.rb +157 -7
- data/lib/coinbase/client/api/trades_api.rb +1 -1
- data/lib/coinbase/client/api/transfers_api.rb +1 -1
- data/lib/coinbase/client/api/users_api.rb +1 -1
- data/lib/coinbase/client/api/wallets_api.rb +1 -1
- data/lib/coinbase/client/api_client.rb +3 -3
- data/lib/coinbase/client/api_error.rb +1 -1
- data/lib/coinbase/client/configuration.rb +1 -1
- data/lib/coinbase/client/models/address.rb +1 -1
- data/lib/coinbase/client/models/address_balance_list.rb +1 -1
- data/lib/coinbase/client/models/address_list.rb +1 -1
- data/lib/coinbase/client/models/asset.rb +1 -1
- data/lib/coinbase/client/models/balance.rb +1 -1
- data/lib/coinbase/client/models/broadcast_trade_request.rb +1 -1
- data/lib/coinbase/client/models/broadcast_transfer_request.rb +1 -1
- data/lib/coinbase/client/models/build_staking_operation_request.rb +1 -1
- data/lib/coinbase/client/models/create_address_request.rb +1 -1
- data/lib/coinbase/client/models/create_server_signer_request.rb +22 -5
- data/lib/coinbase/client/models/create_trade_request.rb +1 -1
- data/lib/coinbase/client/models/create_transfer_request.rb +1 -1
- data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
- data/lib/coinbase/client/models/create_wallet_request_wallet.rb +1 -1
- data/lib/coinbase/client/models/error.rb +1 -1
- data/lib/coinbase/client/models/faucet_transaction.rb +23 -5
- data/lib/coinbase/client/models/feature.rb +1 -1
- data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +258 -0
- data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +330 -0
- data/lib/coinbase/client/models/get_staking_context_request.rb +274 -0
- data/lib/coinbase/client/models/partial_eth_staking_context.rb +254 -0
- data/lib/coinbase/client/models/seed_creation_event.rb +1 -1
- data/lib/coinbase/client/models/seed_creation_event_result.rb +1 -1
- data/lib/coinbase/client/models/server_signer.rb +22 -5
- data/lib/coinbase/client/models/server_signer_event.rb +1 -1
- data/lib/coinbase/client/models/server_signer_event_event.rb +1 -1
- data/lib/coinbase/client/models/server_signer_event_list.rb +1 -1
- data/lib/coinbase/client/models/server_signer_list.rb +1 -1
- data/lib/coinbase/client/models/signature_creation_event.rb +1 -1
- data/lib/coinbase/client/models/signature_creation_event_result.rb +1 -1
- data/lib/coinbase/client/models/{request_faucet_funds200_response.rb → staking_context.rb} +16 -16
- data/lib/coinbase/client/models/staking_context_context.rb +104 -0
- data/lib/coinbase/client/models/staking_operation.rb +15 -12
- data/lib/coinbase/client/models/staking_reward.rb +324 -0
- data/lib/coinbase/client/models/staking_reward_format.rb +40 -0
- data/lib/coinbase/client/models/trade.rb +1 -1
- data/lib/coinbase/client/models/trade_list.rb +1 -1
- data/lib/coinbase/client/models/transaction.rb +1 -1
- data/lib/coinbase/client/models/transaction_type.rb +1 -1
- data/lib/coinbase/client/models/transfer.rb +1 -1
- data/lib/coinbase/client/models/transfer_list.rb +1 -1
- data/lib/coinbase/client/models/user.rb +1 -1
- data/lib/coinbase/client/models/wallet.rb +1 -1
- data/lib/coinbase/client/models/wallet_list.rb +1 -1
- data/lib/coinbase/client/version.rb +1 -1
- data/lib/coinbase/client.rb +11 -1
- data/lib/coinbase/constants.rb +2 -27
- data/lib/coinbase/errors.rb +56 -64
- data/lib/coinbase/faucet_transaction.rb +5 -4
- data/lib/coinbase/network.rb +6 -20
- data/lib/coinbase/pagination.rb +26 -0
- data/lib/coinbase/staking_operation.rb +29 -0
- data/lib/coinbase/staking_reward.rb +79 -0
- data/lib/coinbase/transaction.rb +6 -0
- data/lib/coinbase/user.rb +5 -51
- data/lib/coinbase/wallet.rb +97 -102
- data/lib/coinbase.rb +19 -11
- metadata +17 -17
data/lib/coinbase/wallet.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'digest'
|
4
|
-
require 'jimson'
|
5
4
|
require 'json'
|
6
5
|
require 'money-tree'
|
7
6
|
require 'securerandom'
|
@@ -9,14 +8,14 @@ require 'securerandom'
|
|
9
8
|
module Coinbase
|
10
9
|
# A representation of a Wallet. Wallets come with a single default Address, but can expand to have a set of Addresses,
|
11
10
|
# each of which can hold a balance of one or more Assets. Wallets can create new Addresses, list their addresses,
|
12
|
-
# list their balances, and transfer Assets to other Addresses.
|
13
|
-
# User#import_wallet.
|
11
|
+
# list their balances, and transfer Assets to other Addresses.
|
14
12
|
class Wallet
|
15
|
-
attr_reader :addresses, :model
|
16
|
-
|
17
13
|
# The maximum number of addresses in a Wallet.
|
18
14
|
MAX_ADDRESSES = 20
|
19
15
|
|
16
|
+
# The maximum number of wallets to fetch in a single page.
|
17
|
+
PAGE_LIMIT = 100
|
18
|
+
|
20
19
|
# A representation of ServerSigner status in a Wallet.
|
21
20
|
module ServerSignerStatus
|
22
21
|
# The Wallet is awaiting seed creation by the ServerSigner. At this point,
|
@@ -39,11 +38,31 @@ module Coinbase
|
|
39
38
|
wallets_api.get_wallet(data.wallet_id)
|
40
39
|
end
|
41
40
|
|
42
|
-
|
43
|
-
|
41
|
+
new(model, seed: data.seed)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Enumerates the wallets for the requesting user.
|
45
|
+
# The result is an enumerator that lazily fetches from the server, and can be iterated over,
|
46
|
+
# converted to an array, etc...
|
47
|
+
# @return [Enumerable<Coinbase::Wallet>] Enumerator that returns wallets
|
48
|
+
def list
|
49
|
+
Coinbase::Pagination.enumerate(lambda(&method(:fetch_wallets_page))) do |wallet|
|
50
|
+
Coinbase::Wallet.new(wallet, seed: '')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Fetches a Wallet by its ID.
|
55
|
+
# The returned wallet can be immediately used for signing operations if backed by a server signer.
|
56
|
+
# If the wallet is not backed by a server signer, the wallet's seed will need to be set before
|
57
|
+
# it can be used for signing operations.
|
58
|
+
# @param wallet_id [String] The ID of the Wallet to fetch
|
59
|
+
# @return [Coinbase::Wallet] The fetched Wallet
|
60
|
+
def fetch(wallet_id)
|
61
|
+
model = Coinbase.call_api do
|
62
|
+
wallets_api.get_wallet(wallet_id)
|
44
63
|
end
|
45
64
|
|
46
|
-
new(model, seed:
|
65
|
+
new(model, seed: '')
|
47
66
|
end
|
48
67
|
|
49
68
|
# Creates a new Wallet on the specified Network and generate a default address for it.
|
@@ -58,7 +77,7 @@ module Coinbase
|
|
58
77
|
wallets_api.create_wallet(
|
59
78
|
create_wallet_request: {
|
60
79
|
wallet: {
|
61
|
-
network_id: network_id,
|
80
|
+
network_id: Coinbase.normalize_network(network_id),
|
62
81
|
use_server_signer: Coinbase.use_server_signer?
|
63
82
|
}
|
64
83
|
}
|
@@ -103,7 +122,6 @@ module Coinbase
|
|
103
122
|
self
|
104
123
|
end
|
105
124
|
|
106
|
-
# TODO: Memoize these objects in a thread-safe way at the top-level.
|
107
125
|
def addresses_api
|
108
126
|
Coinbase::Client::AddressesApi.new(Coinbase.configuration.api_client)
|
109
127
|
end
|
@@ -111,6 +129,10 @@ module Coinbase
|
|
111
129
|
def wallets_api
|
112
130
|
Coinbase::Client::WalletsApi.new(Coinbase.configuration.api_client)
|
113
131
|
end
|
132
|
+
|
133
|
+
def fetch_wallets_page(page)
|
134
|
+
wallets_api.list_wallets({ limit: PAGE_LIMIT, page: page })
|
135
|
+
end
|
114
136
|
end
|
115
137
|
|
116
138
|
# Returns a new Wallet object. Do not use this method directly. Instead, use User#create_wallet or
|
@@ -119,21 +141,30 @@ module Coinbase
|
|
119
141
|
# @param seed [String] (Optional) The seed to use for the Wallet. Expects a 32-byte hexadecimal with no 0x prefix.
|
120
142
|
# If nil, a new seed will be generated. If the empty string, no seed is generated, and the Wallet will be
|
121
143
|
# instantiated without a seed and its corresponding private keys.
|
122
|
-
# @param address_models [Array<Coinbase::Client::Address>] (Optional) The models of the addresses already registered
|
123
144
|
# with the Wallet. If not provided, the Wallet will derive the first default address.
|
124
|
-
|
125
|
-
|
126
|
-
validate_seed_and_address_models(seed, address_models) unless Coinbase.use_server_signer?
|
145
|
+
def initialize(model, seed: nil)
|
146
|
+
raise ArgumentError, 'model must be a Wallet' unless model.is_a?(Coinbase::Client::Wallet)
|
127
147
|
|
128
148
|
@model = model
|
129
|
-
@addresses = []
|
130
149
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
150
|
+
return if Coinbase.use_server_signer?
|
151
|
+
|
152
|
+
@master = master_node(seed)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Returns the addresses belonging to the Wallet.
|
156
|
+
# @return [Array<Coinbase::WalletAddress>] The addresses belonging to the Wallet
|
157
|
+
def addresses
|
158
|
+
@addresses ||= begin
|
159
|
+
address_list = Coinbase.call_api do
|
160
|
+
addresses_api.list_addresses(@model.id, { limit: MAX_ADDRESSES })
|
161
|
+
end
|
135
162
|
|
136
|
-
|
163
|
+
# Build the WalletAddress objects, injecting the key if available.
|
164
|
+
address_list.data.each_with_index.map do |address_model, index|
|
165
|
+
build_wallet_address(address_model, index)
|
166
|
+
end
|
167
|
+
end
|
137
168
|
end
|
138
169
|
|
139
170
|
# Returns the Wallet ID.
|
@@ -157,18 +188,22 @@ module Coinbase
|
|
157
188
|
# Sets the seed of the Wallet. This seed is used to derive keys and sign transactions.
|
158
189
|
# @param seed [String] The seed to set. Expects a 32-byte hexadecimal with no 0x prefix.
|
159
190
|
def seed=(seed)
|
160
|
-
raise ArgumentError, 'Seed must be
|
161
|
-
raise 'Seed is already set' unless @master.nil?
|
162
|
-
|
191
|
+
raise ArgumentError, 'Seed must not be empty' if seed.nil? || seed.empty?
|
192
|
+
raise StandardError, 'Seed is already set' unless @master.nil?
|
193
|
+
|
194
|
+
@master = master_node(seed)
|
163
195
|
|
164
|
-
|
196
|
+
# If the addresses are not loaded the keys will be set on them whenever they are loaded.
|
197
|
+
return if @addresses.nil?
|
165
198
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
raise "Seed does not match wallet; cannot find address #{key.address}" if a.nil?
|
199
|
+
# If addresses are already loaded, set the keys on each address.
|
200
|
+
addresses.each_with_index.each do |address, index|
|
201
|
+
key = derive_key(index)
|
170
202
|
|
171
|
-
a
|
203
|
+
# If we derive a key the derived address must match the address from the API.
|
204
|
+
raise StandardError, 'Seed does not match wallet' unless address.id == key.address.to_s
|
205
|
+
|
206
|
+
address.key = key
|
172
207
|
end
|
173
208
|
end
|
174
209
|
|
@@ -178,7 +213,10 @@ module Coinbase
|
|
178
213
|
opts = { create_address_request: {} }
|
179
214
|
|
180
215
|
unless Coinbase.use_server_signer?
|
181
|
-
|
216
|
+
# The index for the next address is the number of addresses already registered.
|
217
|
+
private_key_index = addresses.count
|
218
|
+
|
219
|
+
key = derive_key(private_key_index)
|
182
220
|
|
183
221
|
opts = {
|
184
222
|
create_address_request: {
|
@@ -193,9 +231,12 @@ module Coinbase
|
|
193
231
|
end
|
194
232
|
|
195
233
|
# Auto-reload wallet to set default address on first address creation.
|
196
|
-
reload if
|
234
|
+
reload if default_address.nil?
|
197
235
|
|
198
|
-
|
236
|
+
# Cache the address in our memoized list
|
237
|
+
address = WalletAddress.new(address_model, key)
|
238
|
+
@addresses << address
|
239
|
+
address
|
199
240
|
end
|
200
241
|
|
201
242
|
# Returns the default address of the Wallet.
|
@@ -208,7 +249,7 @@ module Coinbase
|
|
208
249
|
# @param address_id [String] The ID of the Address to retrieve
|
209
250
|
# @return [Address] The Address
|
210
251
|
def address(address_id)
|
211
|
-
|
252
|
+
addresses.find { |address| address.id == address_id }
|
212
253
|
end
|
213
254
|
|
214
255
|
# Returns the list of balances of this Wallet. Balances are aggregated across all Addresses in the Wallet.
|
@@ -413,85 +454,35 @@ module Coinbase
|
|
413
454
|
end
|
414
455
|
end
|
415
456
|
|
457
|
+
# Returns the master node for the given seed.
|
416
458
|
def master_node(seed)
|
417
459
|
return MoneyTree::Master.new if seed.nil?
|
418
460
|
return nil if seed.empty?
|
419
461
|
|
462
|
+
validate_seed(seed)
|
463
|
+
|
420
464
|
MoneyTree::Master.new(seed_hex: seed)
|
421
465
|
end
|
422
466
|
|
423
467
|
def address_path_prefix
|
424
|
-
# TODO:
|
468
|
+
# TODO: Push this logic to the backend.
|
425
469
|
@address_path_prefix ||= case network_id.to_s.split('_').first
|
426
|
-
when 'base'
|
470
|
+
when 'base', 'ethereum'
|
427
471
|
"m/44'/60'/0'/0"
|
428
472
|
else
|
429
473
|
raise ArgumentError, "Unsupported network ID: #{network_id}"
|
430
474
|
end
|
431
475
|
end
|
432
476
|
|
433
|
-
# Derives
|
434
|
-
# @param address_models [Array<Coinbase::Client::Address>] The models of the addresses already registered with the
|
435
|
-
# Wallet
|
436
|
-
def derive_addresses(address_models)
|
437
|
-
return unless address_models.any?
|
438
|
-
|
439
|
-
# Create a map tracking which addresses are already registered with the Wallet.
|
440
|
-
address_map = build_address_map(address_models)
|
441
|
-
|
442
|
-
address_models.each do |address_model|
|
443
|
-
# Derive the addresses using the provided models.
|
444
|
-
derive_address(address_map, address_model)
|
445
|
-
end
|
446
|
-
end
|
447
|
-
|
448
|
-
# Derives an already registered Address in the Wallet.
|
449
|
-
# @param address_map [Hash<String, Boolean>] The map of registered Address IDs
|
450
|
-
# @param address_model [Coinbase::Client::Address] The Address model
|
451
|
-
# @return [Address] The new Address
|
452
|
-
def derive_address(address_map, address_model)
|
453
|
-
key = @master.nil? ? nil : derive_key
|
454
|
-
|
455
|
-
unless key.nil?
|
456
|
-
address_from_key = key.address.to_s
|
457
|
-
raise 'Invalid address' if address_map[address_from_key].nil?
|
458
|
-
end
|
459
|
-
|
460
|
-
cache_address(address_model, key)
|
461
|
-
end
|
462
|
-
|
463
|
-
# Derives a key for an already registered Address in the Wallet.
|
477
|
+
# Derives a key for the given address index.
|
464
478
|
# @return [Eth::Key] The new key
|
465
|
-
def derive_key
|
479
|
+
def derive_key(index)
|
466
480
|
raise 'Cannot derive key for Wallet without seed loaded' if @master.nil?
|
467
481
|
|
468
|
-
path = "#{address_path_prefix}/#{
|
482
|
+
path = "#{address_path_prefix}/#{index}"
|
469
483
|
private_key = @master.node_for_path(path).private_key.to_hex
|
470
|
-
@private_key_index += 1
|
471
|
-
Eth::Key.new(priv: private_key)
|
472
|
-
end
|
473
|
-
|
474
|
-
# Caches an Address on the client-side and increments the address index.
|
475
|
-
# @param address_model [Coinbase::Client::Address] The Address model
|
476
|
-
# @param key [Eth::Key] The private key of the Address
|
477
|
-
# @return [Address] The new Address
|
478
|
-
def cache_address(address_model, key)
|
479
|
-
address = Address.new(address_model, key)
|
480
|
-
@addresses << address
|
481
|
-
address
|
482
|
-
end
|
483
484
|
|
484
|
-
|
485
|
-
# @param address_models [Array<Coinbase::Client::Address>] The models of the addresses already registered with the
|
486
|
-
# Wallet
|
487
|
-
# @return [Hash<String, Boolean>] The Hash of registered Addresses
|
488
|
-
def build_address_map(address_models)
|
489
|
-
address_map = {}
|
490
|
-
address_models.each do |address_model|
|
491
|
-
address_map[address_model.address_id] = true
|
492
|
-
end
|
493
|
-
|
494
|
-
address_map
|
485
|
+
Eth::Key.new(priv: private_key)
|
495
486
|
end
|
496
487
|
|
497
488
|
# Creates an attestation for the Address currently being created.
|
@@ -520,16 +511,9 @@ module Coinbase
|
|
520
511
|
|
521
512
|
# Validates the seed and address models passed to the constructor.
|
522
513
|
# @param seed [String] The seed to use for the Wallet
|
523
|
-
# @
|
524
|
-
|
525
|
-
|
526
|
-
raise ArgumentError, 'Seed must be 32 bytes' if !seed.nil? && !seed.empty? && seed.length != 64
|
527
|
-
|
528
|
-
raise ArgumentError, 'Seed must be present if address_models are provided' if seed.nil? && address_models.any?
|
529
|
-
|
530
|
-
return unless !seed.nil? && seed.empty? && address_models.empty?
|
531
|
-
|
532
|
-
raise ArgumentError, 'Seed must be empty if address_models are not provided'
|
514
|
+
# @raise [ArgumentError] If the seed is invalid
|
515
|
+
def validate_seed(seed)
|
516
|
+
raise ArgumentError, 'Seed must be 32 bytes' unless seed.length == 64
|
533
517
|
end
|
534
518
|
|
535
519
|
# Loads the Hash of Wallet seeds from the given file.
|
@@ -551,6 +535,17 @@ module Coinbase
|
|
551
535
|
pk.dh_compute_key(public_key)
|
552
536
|
end
|
553
537
|
|
538
|
+
def build_wallet_address(address_model, index)
|
539
|
+
# Return an unhydrated wallet address is no master seed is set.
|
540
|
+
return WalletAddress.new(address_model, nil) if @master.nil?
|
541
|
+
|
542
|
+
key = derive_key(index)
|
543
|
+
|
544
|
+
raise StandardError, 'Seed does not match wallet' unless address_model.address_id == key.address.to_s
|
545
|
+
|
546
|
+
WalletAddress.new(address_model, key)
|
547
|
+
end
|
548
|
+
|
554
549
|
def addresses_api
|
555
550
|
@addresses_api ||= Coinbase::Client::AddressesApi.new(Coinbase.configuration.api_client)
|
556
551
|
end
|
data/lib/coinbase.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'coinbase/address'
|
4
|
+
require_relative 'coinbase/address/wallet_address'
|
5
|
+
require_relative 'coinbase/address/external_address'
|
4
6
|
require_relative 'coinbase/asset'
|
5
7
|
require_relative 'coinbase/authenticator'
|
6
8
|
require_relative 'coinbase/balance'
|
@@ -11,12 +13,15 @@ require_relative 'coinbase/errors'
|
|
11
13
|
require_relative 'coinbase/faucet_transaction'
|
12
14
|
require_relative 'coinbase/middleware'
|
13
15
|
require_relative 'coinbase/network'
|
16
|
+
require_relative 'coinbase/pagination'
|
14
17
|
require_relative 'coinbase/trade'
|
15
18
|
require_relative 'coinbase/transfer'
|
16
19
|
require_relative 'coinbase/transaction'
|
17
20
|
require_relative 'coinbase/user'
|
18
21
|
require_relative 'coinbase/wallet'
|
19
22
|
require_relative 'coinbase/server_signer'
|
23
|
+
require_relative 'coinbase/staking_operation'
|
24
|
+
require_relative 'coinbase/staking_reward'
|
20
25
|
require 'json'
|
21
26
|
|
22
27
|
# The Coinbase SDK.
|
@@ -55,13 +60,10 @@ module Coinbase
|
|
55
60
|
|
56
61
|
# Configuration object for the Coinbase SDK.
|
57
62
|
class Configuration
|
58
|
-
attr_reader :base_sepolia_rpc_url, :base_sepolia_client
|
59
63
|
attr_accessor :api_url, :api_key_name, :api_key_private_key, :debug_api, :use_server_signer
|
60
64
|
|
61
65
|
# Initializes the configuration object.
|
62
66
|
def initialize
|
63
|
-
@base_sepolia_rpc_url = 'https://sepolia.base.org'
|
64
|
-
@base_sepolia_client = Jimson::Client.new(@base_sepolia_rpc_url)
|
65
67
|
@api_url = 'https://api.cdp.coinbase.com'
|
66
68
|
@debug_api = false
|
67
69
|
@use_server_signer = false
|
@@ -82,13 +84,6 @@ module Coinbase
|
|
82
84
|
@api_key_private_key = data['privateKey']
|
83
85
|
end
|
84
86
|
|
85
|
-
# Sets the Base Sepolia RPC URL.
|
86
|
-
# @param new_base_sepolia_rpc_url [String] the new Base Sepolia RPC URL
|
87
|
-
def base_sepolia_rpc_url=(new_base_sepolia_rpc_url)
|
88
|
-
@base_sepolia_rpc_url = new_base_sepolia_rpc_url
|
89
|
-
@base_sepolia_client = Jimson::Client.new(@base_sepolia_rpc_url)
|
90
|
-
end
|
91
|
-
|
92
87
|
# Returns the API client.
|
93
88
|
# @return [Coinbase::Client::ApiClient] the API client
|
94
89
|
def api_client
|
@@ -109,6 +104,13 @@ module Coinbase
|
|
109
104
|
value.to_s.gsub('-', '_').to_sym
|
110
105
|
end
|
111
106
|
|
107
|
+
# Converts a network symbol to a string, replacing underscores with hyphens.
|
108
|
+
# @param network_sym [Symbol] the network symbol to convert
|
109
|
+
# @return [String] the converted string
|
110
|
+
def self.normalize_network(network_sym)
|
111
|
+
network_sym.to_s.gsub(/_/, '-')
|
112
|
+
end
|
113
|
+
|
112
114
|
# Loads the default user.
|
113
115
|
# @return [Coinbase::User] the default user
|
114
116
|
def self.load_default_user
|
@@ -122,7 +124,7 @@ module Coinbase
|
|
122
124
|
def self.call_api
|
123
125
|
yield
|
124
126
|
rescue Coinbase::Client::ApiError => e
|
125
|
-
raise Coinbase::APIError.from_error(e)
|
127
|
+
raise Coinbase::APIError.from_error(e), cause: nil
|
126
128
|
rescue StandardError => e
|
127
129
|
raise e
|
128
130
|
end
|
@@ -132,4 +134,10 @@ module Coinbase
|
|
132
134
|
def self.use_server_signer?
|
133
135
|
Coinbase.configuration.use_server_signer
|
134
136
|
end
|
137
|
+
|
138
|
+
# Returns whether the SDK is configured.
|
139
|
+
# @return [bool] whether the SDK is configured
|
140
|
+
def self.configured?
|
141
|
+
!Coinbase.configuration.api_key_name.nil? && !Coinbase.configuration.api_key_private_key.nil?
|
142
|
+
end
|
135
143
|
end
|
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.0.
|
4
|
+
version: 0.0.9
|
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-06-
|
11
|
+
date: 2024-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: jimson
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: jwt
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -242,12 +228,16 @@ extra_rdoc_files: []
|
|
242
228
|
files:
|
243
229
|
- lib/coinbase.rb
|
244
230
|
- lib/coinbase/address.rb
|
231
|
+
- lib/coinbase/address/external_address.rb
|
232
|
+
- lib/coinbase/address/wallet_address.rb
|
245
233
|
- lib/coinbase/asset.rb
|
246
234
|
- lib/coinbase/authenticator.rb
|
247
235
|
- lib/coinbase/balance.rb
|
248
236
|
- lib/coinbase/balance_map.rb
|
249
237
|
- lib/coinbase/client.rb
|
250
238
|
- lib/coinbase/client/api/addresses_api.rb
|
239
|
+
- lib/coinbase/client/api/assets_api.rb
|
240
|
+
- lib/coinbase/client/api/external_addresses_api.rb
|
251
241
|
- lib/coinbase/client/api/server_signers_api.rb
|
252
242
|
- lib/coinbase/client/api/stake_api.rb
|
253
243
|
- lib/coinbase/client/api/trades_api.rb
|
@@ -274,7 +264,10 @@ files:
|
|
274
264
|
- lib/coinbase/client/models/error.rb
|
275
265
|
- lib/coinbase/client/models/faucet_transaction.rb
|
276
266
|
- lib/coinbase/client/models/feature.rb
|
277
|
-
- lib/coinbase/client/models/
|
267
|
+
- lib/coinbase/client/models/fetch_staking_rewards200_response.rb
|
268
|
+
- lib/coinbase/client/models/fetch_staking_rewards_request.rb
|
269
|
+
- lib/coinbase/client/models/get_staking_context_request.rb
|
270
|
+
- lib/coinbase/client/models/partial_eth_staking_context.rb
|
278
271
|
- lib/coinbase/client/models/seed_creation_event.rb
|
279
272
|
- lib/coinbase/client/models/seed_creation_event_result.rb
|
280
273
|
- lib/coinbase/client/models/server_signer.rb
|
@@ -284,7 +277,11 @@ files:
|
|
284
277
|
- lib/coinbase/client/models/server_signer_list.rb
|
285
278
|
- lib/coinbase/client/models/signature_creation_event.rb
|
286
279
|
- lib/coinbase/client/models/signature_creation_event_result.rb
|
280
|
+
- lib/coinbase/client/models/staking_context.rb
|
281
|
+
- lib/coinbase/client/models/staking_context_context.rb
|
287
282
|
- lib/coinbase/client/models/staking_operation.rb
|
283
|
+
- lib/coinbase/client/models/staking_reward.rb
|
284
|
+
- lib/coinbase/client/models/staking_reward_format.rb
|
288
285
|
- lib/coinbase/client/models/trade.rb
|
289
286
|
- lib/coinbase/client/models/trade_list.rb
|
290
287
|
- lib/coinbase/client/models/transaction.rb
|
@@ -300,7 +297,10 @@ files:
|
|
300
297
|
- lib/coinbase/faucet_transaction.rb
|
301
298
|
- lib/coinbase/middleware.rb
|
302
299
|
- lib/coinbase/network.rb
|
300
|
+
- lib/coinbase/pagination.rb
|
303
301
|
- lib/coinbase/server_signer.rb
|
302
|
+
- lib/coinbase/staking_operation.rb
|
303
|
+
- lib/coinbase/staking_reward.rb
|
304
304
|
- lib/coinbase/trade.rb
|
305
305
|
- lib/coinbase/transaction.rb
|
306
306
|
- lib/coinbase/transfer.rb
|