coinbase-sdk 0.0.14 → 0.1.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 +31 -21
- data/lib/coinbase/address.rb +51 -17
- data/lib/coinbase/asset.rb +11 -8
- data/lib/coinbase/client/api/contract_events_api.rb +17 -9
- data/lib/coinbase/client/api/external_addresses_api.rb +85 -0
- data/lib/coinbase/client/api/networks_api.rb +85 -0
- data/lib/coinbase/client/api/stake_api.rb +74 -195
- data/lib/coinbase/client/api/validators_api.rb +2 -2
- data/lib/coinbase/client/api/wallet_stake_api.rb +263 -0
- data/lib/coinbase/client/models/address.rb +21 -4
- data/lib/coinbase/client/models/{native_eth_staking_context.rb → address_historical_balance_list.rb} +39 -35
- data/lib/coinbase/client/models/contract_event.rb +99 -8
- data/lib/coinbase/client/models/create_address_request.rb +14 -4
- data/lib/coinbase/client/models/create_transfer_request.rb +14 -4
- data/lib/coinbase/client/models/ethereum_validator_metadata.rb +11 -11
- data/lib/coinbase/client/models/feature.rb +2 -1
- data/lib/coinbase/client/models/feature_set.rb +307 -0
- data/lib/coinbase/client/models/{partial_eth_staking_context.rb → fetch_historical_staking_balances200_response.rb} +39 -35
- data/lib/coinbase/client/models/historical_balance.rb +273 -0
- data/lib/coinbase/client/models/network.rb +365 -0
- data/lib/coinbase/client/models/network_identifier.rb +44 -0
- data/lib/coinbase/client/models/sponsored_send.rb +338 -0
- data/lib/coinbase/client/models/staking_balance.rb +289 -0
- data/lib/coinbase/client/models/staking_context_context.rb +222 -74
- data/lib/coinbase/client/models/staking_operation.rb +2 -2
- data/lib/coinbase/client/models/staking_reward.rb +22 -6
- data/lib/coinbase/client/models/staking_reward_format.rb +2 -1
- data/lib/coinbase/client/models/staking_reward_usd_value.rb +257 -0
- data/lib/coinbase/client/models/transaction.rb +17 -7
- data/lib/coinbase/client/models/transaction_type.rb +2 -1
- data/lib/coinbase/client/models/transfer.rb +101 -8
- data/lib/coinbase/client/models/validator.rb +23 -2
- data/lib/coinbase/client/models/validator_status.rb +52 -0
- data/lib/coinbase/client/models/wallet.rb +13 -16
- data/lib/coinbase/client/models/webhook_event_type.rb +2 -1
- data/lib/coinbase/client.rb +12 -3
- data/lib/coinbase/constants.rb +0 -10
- data/lib/coinbase/contract_event.rb +104 -0
- data/lib/coinbase/correlation.rb +30 -0
- data/lib/coinbase/destination.rb +11 -9
- data/lib/coinbase/errors.rb +14 -0
- data/lib/coinbase/historical_balance.rb +53 -0
- data/lib/coinbase/middleware.rb +2 -0
- data/lib/coinbase/network.rb +103 -20
- data/lib/coinbase/server_signer.rb +14 -3
- data/lib/coinbase/smart_contract.rb +106 -0
- data/lib/coinbase/sponsored_send.rb +110 -0
- data/lib/coinbase/staking_balance.rb +92 -0
- data/lib/coinbase/staking_operation.rb +134 -36
- data/lib/coinbase/staking_reward.rb +18 -0
- data/lib/coinbase/trade.rb +10 -9
- data/lib/coinbase/transaction.rb +13 -3
- data/lib/coinbase/transfer.rb +65 -36
- data/lib/coinbase/validator.rb +18 -10
- data/lib/coinbase/version.rb +5 -0
- data/lib/coinbase/wallet/data.rb +31 -0
- data/lib/coinbase/wallet.rb +143 -182
- data/lib/coinbase/webhook.rb +181 -0
- data/lib/coinbase.rb +64 -21
- metadata +51 -5
- data/lib/coinbase/user.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c8786bfb21ed8e6e8533244582389e90f94a7b5587b4995666ad5e02424fb30
|
4
|
+
data.tar.gz: cb4dca1f054511410761372ced09d65491ee38e21b1d9ad8b2fb90ce08e80869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2226115a66b26e4bd42429506b91ce04617440e4ce79744eddea43881d53b6814341e110fb4adf0e6967ef7e2ee57b5f13aacb44d074bb170564808bc86ec216
|
7
|
+
data.tar.gz: 7ee730264721461357d56f0ad7e0630036ca85d28ab120101c6813e64fca9427d919fc1a35d8c49ffc39cf1eb9a8ca34fa492211c4c86397afd88a82f685f0c8
|
@@ -39,8 +39,11 @@ module Coinbase
|
|
39
39
|
# @param asset_id [Symbol] The ID of the Asset to send. For Ether, :eth, :gwei, and :wei are supported.
|
40
40
|
# @param destination [Wallet | Address | String] The destination of the transfer. If a Wallet, sends to the Wallet's
|
41
41
|
# default address. If a String, interprets it as the address ID.
|
42
|
+
# @param gasless [Boolean] Whether gas fee for the transfer should be covered by Coinbase.
|
43
|
+
# Defaults to false. Check the API documentation for network and asset support.
|
44
|
+
# Whether the transfer should be gasless. Defaults to false.
|
42
45
|
# @return [Coinbase::Transfer] The Transfer object.
|
43
|
-
def transfer(amount, asset_id, destination)
|
46
|
+
def transfer(amount, asset_id, destination, gasless: false)
|
44
47
|
ensure_can_sign!
|
45
48
|
ensure_sufficient_balance!(amount, asset_id)
|
46
49
|
|
@@ -49,15 +52,15 @@ module Coinbase
|
|
49
52
|
amount: amount,
|
50
53
|
asset_id: asset_id,
|
51
54
|
destination: destination,
|
52
|
-
|
53
|
-
wallet_id: wallet_id
|
55
|
+
network: network,
|
56
|
+
wallet_id: wallet_id,
|
57
|
+
gasless: gasless
|
54
58
|
)
|
55
59
|
|
56
60
|
# If a server signer is managing keys, it will sign and broadcast the underlying transfer transaction out of band.
|
57
61
|
return transfer if Coinbase.use_server_signer?
|
58
62
|
|
59
|
-
transfer.
|
60
|
-
|
63
|
+
transfer.sign(@key)
|
61
64
|
transfer.broadcast!
|
62
65
|
transfer
|
63
66
|
end
|
@@ -77,7 +80,7 @@ module Coinbase
|
|
77
80
|
amount: amount,
|
78
81
|
from_asset_id: from_asset_id,
|
79
82
|
to_asset_id: to_asset_id,
|
80
|
-
|
83
|
+
network: network,
|
81
84
|
wallet_id: wallet_id
|
82
85
|
)
|
83
86
|
|
@@ -97,11 +100,16 @@ module Coinbase
|
|
97
100
|
# @param asset_id [Symbol] The ID of the Asset to stake. For Ether, :eth, :gwei, and :wei are supported.
|
98
101
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
99
102
|
# @param options [Hash] Additional options for the stake operation
|
103
|
+
# @param interval_seconds [Integer] The number of seconds to wait between polling for updates. Defaults to 5.
|
104
|
+
# @param timeout_seconds [Integer] The number of seconds to wait before timing out. Defaults to 600.
|
100
105
|
# @return [Coinbase::StakingOperation] The staking operation
|
101
|
-
|
106
|
+
# @raise [Timeout::Error] if the Staking Operation takes longer than the given timeout.
|
107
|
+
def stake(amount, asset_id, mode: :default, options: {}, interval_seconds: 5, timeout_seconds: 600)
|
102
108
|
validate_can_perform_staking_action!(amount, asset_id, 'stakeable_balance', mode, options)
|
103
109
|
|
104
|
-
|
110
|
+
op = StakingOperation.create(amount, network, asset_id, id, wallet_id, 'stake', mode, options)
|
111
|
+
|
112
|
+
op.complete(@key, interval_seconds: interval_seconds, timeout_seconds: timeout_seconds)
|
105
113
|
end
|
106
114
|
|
107
115
|
# Unstakes the given amount of the given Asset
|
@@ -109,11 +117,16 @@ module Coinbase
|
|
109
117
|
# @param asset_id [Symbol] The ID of the Asset to stake. For Ether, :eth, :gwei, and :wei are supported.
|
110
118
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
111
119
|
# @param options [Hash] Additional options for the stake operation
|
120
|
+
# @param interval_seconds [Integer] The number of seconds to wait between polling for updates. Defaults to 5.
|
121
|
+
# @param timeout_seconds [Integer] The number of seconds to wait before timing out. Defaults to 600.
|
112
122
|
# @return [Coinbase::StakingOperation] The staking operation
|
113
|
-
|
123
|
+
# @raise [Timeout::Error] if the Staking Operation takes longer than the given timeout.
|
124
|
+
def unstake(amount, asset_id, mode: :default, options: {}, interval_seconds: 5, timeout_seconds: 600)
|
114
125
|
validate_can_perform_staking_action!(amount, asset_id, 'unstakeable_balance', mode, options)
|
115
126
|
|
116
|
-
|
127
|
+
op = StakingOperation.create(amount, network, asset_id, id, wallet_id, 'unstake', mode, options)
|
128
|
+
|
129
|
+
op.complete(@key, interval_seconds: interval_seconds, timeout_seconds: timeout_seconds)
|
117
130
|
end
|
118
131
|
|
119
132
|
# Claims the given amount of the given Asset
|
@@ -121,11 +134,16 @@ module Coinbase
|
|
121
134
|
# @param asset_id [Symbol] The ID of the Asset to stake. For Ether, :eth, :gwei, and :wei are supported.
|
122
135
|
# @param mode [Symbol] The staking mode. Defaults to :default.
|
123
136
|
# @param options [Hash] Additional options for the stake operation
|
137
|
+
# @param interval_seconds [Integer] The number of seconds to wait between polling for updates. Defaults to 5.
|
138
|
+
# @param timeout_seconds [Integer] The number of seconds to wait before timing out. Defaults to 600.
|
124
139
|
# @return [Coinbase::StakingOperation] The staking operation
|
125
|
-
|
140
|
+
# @raise [Timeout::Error] if the Staking Operation takes longer than the given timeout.
|
141
|
+
def claim_stake(amount, asset_id, mode: :default, options: {}, interval_seconds: 5, timeout_seconds: 600)
|
126
142
|
validate_can_perform_staking_action!(amount, asset_id, 'claimable_balance', mode, options)
|
127
143
|
|
128
|
-
|
144
|
+
op = StakingOperation.create(amount, network, asset_id, id, wallet_id, 'claim_stake', mode, options)
|
145
|
+
|
146
|
+
op.complete(@key, interval_seconds: interval_seconds, timeout_seconds: timeout_seconds)
|
129
147
|
end
|
130
148
|
|
131
149
|
# Returns whether the Address has a private key backing it to sign transactions.
|
@@ -161,7 +179,7 @@ module Coinbase
|
|
161
179
|
# Returns a String representation of the WalletAddress.
|
162
180
|
# @return [String] a String representation of the WalletAddress
|
163
181
|
def to_s
|
164
|
-
"Coinbase::Address{id: '#{id}', network_id: '#{
|
182
|
+
"Coinbase::Address{id: '#{id}', network_id: '#{network.id}', wallet_id: '#{wallet_id}'}"
|
165
183
|
end
|
166
184
|
|
167
185
|
private
|
@@ -180,13 +198,5 @@ module Coinbase
|
|
180
198
|
|
181
199
|
raise InsufficientFundsError.new(amount, current_balance)
|
182
200
|
end
|
183
|
-
|
184
|
-
def complete_staking_operation(amount, asset_id, action, mode: :default, options: {})
|
185
|
-
op = StakingOperation.create(amount, network_id, asset_id, id, wallet_id, action, mode, options)
|
186
|
-
op.transactions.each do |transaction|
|
187
|
-
transaction.sign(@key)
|
188
|
-
end
|
189
|
-
op.broadcast!
|
190
|
-
end
|
191
201
|
end
|
192
202
|
end
|
data/lib/coinbase/address.rb
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Coinbase
|
4
|
-
# A representation of a blockchain Address, which is a user-controlled account on a Network.
|
5
|
-
# send and receive Assets.
|
6
|
-
# @attr_reader [Symbol] network_id The Network ID
|
7
|
-
# @attr_reader [String] id The onchain Address ID
|
4
|
+
# A representation of a blockchain Address, which is a user-controlled account on a Network.
|
5
|
+
# Addresses are used to send and receive Assets.
|
8
6
|
class Address
|
9
|
-
attr_reader :
|
7
|
+
attr_reader :network, :id
|
10
8
|
|
11
9
|
# Returns a new Address object.
|
12
|
-
# @param
|
10
|
+
# @param network [Coinbase::Network, Symbol] The Network or Network ID
|
13
11
|
# @param id [String] The onchain Address ID
|
14
|
-
def initialize(
|
15
|
-
@
|
12
|
+
def initialize(network, id)
|
13
|
+
@network = Coinbase::Network.from_id(network)
|
16
14
|
@id = id
|
17
15
|
end
|
18
16
|
|
19
17
|
# Returns a String representation of the Address.
|
20
18
|
# @return [String] a String representation of the Address
|
21
19
|
def to_s
|
22
|
-
|
20
|
+
Coinbase.pretty_print_object(self.class, id: id, network_id: network.id)
|
23
21
|
end
|
24
22
|
|
25
23
|
# Same as to_s.
|
@@ -39,7 +37,7 @@ module Coinbase
|
|
39
37
|
# in ETH.
|
40
38
|
def balances
|
41
39
|
response = Coinbase.call_api do
|
42
|
-
addresses_api.list_external_address_balances(
|
40
|
+
addresses_api.list_external_address_balances(network.normalized_id, id)
|
43
41
|
end
|
44
42
|
|
45
43
|
Coinbase::BalanceMap.from_balances(response.data)
|
@@ -51,7 +49,7 @@ module Coinbase
|
|
51
49
|
def balance(asset_id)
|
52
50
|
response = Coinbase.call_api do
|
53
51
|
addresses_api.get_external_address_balance(
|
54
|
-
|
52
|
+
network.normalized_id,
|
55
53
|
id,
|
56
54
|
Coinbase::Asset.primary_denomination(asset_id).to_s
|
57
55
|
)
|
@@ -62,6 +60,18 @@ module Coinbase
|
|
62
60
|
Coinbase::Balance.from_model_and_asset_id(response, asset_id).amount
|
63
61
|
end
|
64
62
|
|
63
|
+
# Enumerates the historical balances for a given asset belonging of address.
|
64
|
+
# The result is an enumerator that lazily fetches from the server, and can be iterated over,
|
65
|
+
# converted to an array, etc...
|
66
|
+
# @return [Enumerable<Coinbase::HistoricalBalance>] Enumerator that returns historical_balance
|
67
|
+
def historical_balances(asset_id)
|
68
|
+
Coinbase::Pagination.enumerate(
|
69
|
+
->(page) { list_page(asset_id, page) }
|
70
|
+
) do |historical_balance|
|
71
|
+
Coinbase::HistoricalBalance.from_model(historical_balance)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
65
75
|
# Requests funds for the address from the faucet and returns the faucet transaction.
|
66
76
|
# This is only supported on testnet networks.
|
67
77
|
# @return [Coinbase::FaucetTransaction] The successful faucet transaction
|
@@ -70,7 +80,7 @@ module Coinbase
|
|
70
80
|
def faucet
|
71
81
|
Coinbase.call_api do
|
72
82
|
Coinbase::FaucetTransaction.new(
|
73
|
-
addresses_api.request_external_faucet_funds(
|
83
|
+
addresses_api.request_external_faucet_funds(network.normalized_id, id)
|
74
84
|
)
|
75
85
|
end
|
76
86
|
end
|
@@ -85,7 +95,7 @@ module Coinbase
|
|
85
95
|
def build_stake_operation(amount, asset_id, mode: :default, options: {})
|
86
96
|
validate_can_perform_staking_action!(amount, asset_id, 'stakeable_balance', mode, options)
|
87
97
|
|
88
|
-
StakingOperation.build(amount,
|
98
|
+
StakingOperation.build(amount, network, asset_id, id, 'stake', mode, options)
|
89
99
|
end
|
90
100
|
|
91
101
|
# Builds an unstake operation for the supplied asset.
|
@@ -97,7 +107,7 @@ module Coinbase
|
|
97
107
|
def build_unstake_operation(amount, asset_id, mode: :default, options: {})
|
98
108
|
validate_can_perform_staking_action!(amount, asset_id, 'unstakeable_balance', mode, options)
|
99
109
|
|
100
|
-
StakingOperation.build(amount,
|
110
|
+
StakingOperation.build(amount, network, asset_id, id, 'unstake', mode, options)
|
101
111
|
end
|
102
112
|
|
103
113
|
# Builds a claim_stake operation for the supplied asset.
|
@@ -109,7 +119,7 @@ module Coinbase
|
|
109
119
|
def build_claim_stake_operation(amount, asset_id, mode: :default, options: {})
|
110
120
|
validate_can_perform_staking_action!(amount, asset_id, 'claimable_balance', mode, options)
|
111
121
|
|
112
|
-
StakingOperation.build(amount,
|
122
|
+
StakingOperation.build(amount, network, asset_id, id, 'claim_stake', mode, options)
|
113
123
|
end
|
114
124
|
|
115
125
|
# Retrieves the balances used for staking for the supplied asset.
|
@@ -125,7 +135,7 @@ module Coinbase
|
|
125
135
|
stake_api.get_staking_context(
|
126
136
|
{
|
127
137
|
asset_id: asset_id,
|
128
|
-
network_id:
|
138
|
+
network_id: network.normalized_id,
|
129
139
|
address_id: id,
|
130
140
|
options: {
|
131
141
|
mode: mode
|
@@ -185,7 +195,7 @@ module Coinbase
|
|
185
195
|
# @return [Enumerable<Coinbase::StakingReward>] The staking rewards
|
186
196
|
def staking_rewards(asset_id, start_time: DateTime.now.prev_week(1), end_time: DateTime.now, format: :usd)
|
187
197
|
StakingReward.list(
|
188
|
-
|
198
|
+
network,
|
189
199
|
asset_id,
|
190
200
|
[id],
|
191
201
|
start_time: start_time,
|
@@ -194,6 +204,21 @@ module Coinbase
|
|
194
204
|
)
|
195
205
|
end
|
196
206
|
|
207
|
+
# Fetches the historical staking balances for the address.
|
208
|
+
# @param asset_id [Symbol] The asset to retrieve staking rewards for
|
209
|
+
# @param start_time [Time] The start time for the rewards. Defaults to 1 week ago.
|
210
|
+
# @param end_time [Time] The end time for the rewards. Defaults to the current time.
|
211
|
+
# @return [Enumerable<Coinbase::StakingBalance>] The staking rewards
|
212
|
+
def historical_staking_balances(asset_id, start_time: DateTime.now.prev_week(1), end_time: DateTime.now)
|
213
|
+
StakingBalance.list(
|
214
|
+
network,
|
215
|
+
asset_id,
|
216
|
+
id,
|
217
|
+
start_time: start_time,
|
218
|
+
end_time: end_time
|
219
|
+
)
|
220
|
+
end
|
221
|
+
|
197
222
|
private
|
198
223
|
|
199
224
|
def validate_can_perform_staking_action!(amount, asset_id, balance_type, mode, options)
|
@@ -208,5 +233,14 @@ module Coinbase
|
|
208
233
|
def stake_api
|
209
234
|
@stake_api ||= Coinbase::Client::StakeApi.new(Coinbase.configuration.api_client)
|
210
235
|
end
|
236
|
+
|
237
|
+
def list_page(asset_id, page)
|
238
|
+
addresses_api.list_address_historical_balance(
|
239
|
+
network.normalized_id,
|
240
|
+
id,
|
241
|
+
Coinbase::Asset.primary_denomination(asset_id).to_s,
|
242
|
+
{ limit: DEFAULT_PAGE_LIMIT, page: page }
|
243
|
+
)
|
244
|
+
end
|
211
245
|
end
|
212
246
|
end
|
data/lib/coinbase/asset.rb
CHANGED
@@ -35,7 +35,7 @@ module Coinbase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
new(
|
38
|
-
|
38
|
+
network: Coinbase.to_sym(asset_model.network_id),
|
39
39
|
asset_id: asset_id || Coinbase.to_sym(asset_model.asset_id),
|
40
40
|
address_id: asset_model.contract_address,
|
41
41
|
decimals: decimals
|
@@ -43,12 +43,15 @@ module Coinbase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
# Fetches the Asset with the provided Asset ID.
|
46
|
+
# @param network [Coinbase::Network, Symbol] The Network or Network ID
|
46
47
|
# @param asset_id [Symbol] The Asset ID
|
47
48
|
# @return [Coinbase::Asset] The Asset
|
48
|
-
def fetch(
|
49
|
+
def fetch(network, asset_id)
|
50
|
+
network = Coinbase::Network.from_id(network)
|
51
|
+
|
49
52
|
asset_model = Coinbase.call_api do
|
50
53
|
assets_api.get_asset(
|
51
|
-
|
54
|
+
network.normalized_id,
|
52
55
|
primary_denomination(asset_id).to_s
|
53
56
|
)
|
54
57
|
end
|
@@ -65,18 +68,18 @@ module Coinbase
|
|
65
68
|
|
66
69
|
# Returns a new Asset object. Do not use this method. Instead, use the Asset constants defined in
|
67
70
|
# the Coinbase module.
|
68
|
-
# @param
|
71
|
+
# @param network [Symbol] The Network or Network ID to which the Asset belongs
|
69
72
|
# @param asset_id [Symbol] The Asset ID
|
70
73
|
# @param address_id [String] (Optional) The Asset's address ID, if one exists
|
71
74
|
# @param decimals [Integer] (Optional) The number of decimal places the Asset uses
|
72
|
-
def initialize(
|
73
|
-
@
|
75
|
+
def initialize(network:, asset_id:, decimals:, address_id: nil)
|
76
|
+
@network = Coinbase::Network.from_id(network)
|
74
77
|
@asset_id = asset_id
|
75
78
|
@address_id = address_id
|
76
79
|
@decimals = decimals
|
77
80
|
end
|
78
81
|
|
79
|
-
attr_reader :
|
82
|
+
attr_reader :network, :asset_id, :address_id, :decimals
|
80
83
|
|
81
84
|
# Converts the amount of the Asset from atomic to whole units.
|
82
85
|
# @param atomic_amount [Integer, Float, BigDecimal] The atomic amount to convert to whole units.
|
@@ -103,7 +106,7 @@ module Coinbase
|
|
103
106
|
# Returns a string representation of the Asset.
|
104
107
|
# @return [String] a string representation of the Asset
|
105
108
|
def to_s
|
106
|
-
"Coinbase::Asset{network_id: '#{
|
109
|
+
"Coinbase::Asset{network_id: '#{network.id}', asset_id: '#{asset_id}', decimals: '#{decimals}'" \
|
107
110
|
"#{address_id.nil? ? '' : ", address_id: '#{address_id}'"}}"
|
108
111
|
end
|
109
112
|
|
@@ -24,15 +24,15 @@ module Coinbase::Client
|
|
24
24
|
# @param network_id [String] Unique identifier for the blockchain network
|
25
25
|
# @param protocol_name [String] Case-sensitive name of the blockchain protocol
|
26
26
|
# @param contract_address [String] EVM address of the smart contract (42 characters, including '0x', in lowercase)
|
27
|
+
# @param contract_name [String] Case-sensitive name of the specific contract within the project
|
28
|
+
# @param event_name [String] Case-sensitive name of the event to filter for in the contract's logs
|
27
29
|
# @param from_block_height [Integer] Lower bound of the block range to query (inclusive)
|
28
30
|
# @param to_block_height [Integer] Upper bound of the block range to query (inclusive)
|
29
31
|
# @param [Hash] opts the optional parameters
|
30
|
-
# @option opts [String] :contract_name Case-sensitive name of the specific contract within the project
|
31
|
-
# @option opts [String] :event_name Case-sensitive name of the event to filter for in the contract's logs
|
32
32
|
# @option opts [String] :next_page Pagination token for retrieving the next set of results
|
33
33
|
# @return [ContractEventList]
|
34
|
-
def list_contract_events(network_id, protocol_name, contract_address, from_block_height, to_block_height, opts = {})
|
35
|
-
data, _status_code, _headers = list_contract_events_with_http_info(network_id, protocol_name, contract_address, from_block_height, to_block_height, opts)
|
34
|
+
def list_contract_events(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, opts = {})
|
35
|
+
data, _status_code, _headers = list_contract_events_with_http_info(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, opts)
|
36
36
|
data
|
37
37
|
end
|
38
38
|
|
@@ -41,14 +41,14 @@ module Coinbase::Client
|
|
41
41
|
# @param network_id [String] Unique identifier for the blockchain network
|
42
42
|
# @param protocol_name [String] Case-sensitive name of the blockchain protocol
|
43
43
|
# @param contract_address [String] EVM address of the smart contract (42 characters, including '0x', in lowercase)
|
44
|
+
# @param contract_name [String] Case-sensitive name of the specific contract within the project
|
45
|
+
# @param event_name [String] Case-sensitive name of the event to filter for in the contract's logs
|
44
46
|
# @param from_block_height [Integer] Lower bound of the block range to query (inclusive)
|
45
47
|
# @param to_block_height [Integer] Upper bound of the block range to query (inclusive)
|
46
48
|
# @param [Hash] opts the optional parameters
|
47
|
-
# @option opts [String] :contract_name Case-sensitive name of the specific contract within the project
|
48
|
-
# @option opts [String] :event_name Case-sensitive name of the event to filter for in the contract's logs
|
49
49
|
# @option opts [String] :next_page Pagination token for retrieving the next set of results
|
50
50
|
# @return [Array<(ContractEventList, Integer, Hash)>] ContractEventList data, response status code and response headers
|
51
|
-
def list_contract_events_with_http_info(network_id, protocol_name, contract_address, from_block_height, to_block_height, opts = {})
|
51
|
+
def list_contract_events_with_http_info(network_id, protocol_name, contract_address, contract_name, event_name, from_block_height, to_block_height, opts = {})
|
52
52
|
if @api_client.config.debugging
|
53
53
|
@api_client.config.logger.debug 'Calling API: ContractEventsApi.list_contract_events ...'
|
54
54
|
end
|
@@ -64,6 +64,14 @@ module Coinbase::Client
|
|
64
64
|
if @api_client.config.client_side_validation && contract_address.nil?
|
65
65
|
fail ArgumentError, "Missing the required parameter 'contract_address' when calling ContractEventsApi.list_contract_events"
|
66
66
|
end
|
67
|
+
# verify the required parameter 'contract_name' is set
|
68
|
+
if @api_client.config.client_side_validation && contract_name.nil?
|
69
|
+
fail ArgumentError, "Missing the required parameter 'contract_name' when calling ContractEventsApi.list_contract_events"
|
70
|
+
end
|
71
|
+
# verify the required parameter 'event_name' is set
|
72
|
+
if @api_client.config.client_side_validation && event_name.nil?
|
73
|
+
fail ArgumentError, "Missing the required parameter 'event_name' when calling ContractEventsApi.list_contract_events"
|
74
|
+
end
|
67
75
|
# verify the required parameter 'from_block_height' is set
|
68
76
|
if @api_client.config.client_side_validation && from_block_height.nil?
|
69
77
|
fail ArgumentError, "Missing the required parameter 'from_block_height' when calling ContractEventsApi.list_contract_events"
|
@@ -78,10 +86,10 @@ module Coinbase::Client
|
|
78
86
|
# query parameters
|
79
87
|
query_params = opts[:query_params] || {}
|
80
88
|
query_params[:'protocol_name'] = protocol_name
|
89
|
+
query_params[:'contract_name'] = contract_name
|
90
|
+
query_params[:'event_name'] = event_name
|
81
91
|
query_params[:'from_block_height'] = from_block_height
|
82
92
|
query_params[:'to_block_height'] = to_block_height
|
83
|
-
query_params[:'contract_name'] = opts[:'contract_name'] if !opts[:'contract_name'].nil?
|
84
|
-
query_params[:'event_name'] = opts[:'event_name'] if !opts[:'event_name'].nil?
|
85
93
|
query_params[:'next_page'] = opts[:'next_page'] if !opts[:'next_page'].nil?
|
86
94
|
|
87
95
|
# header parameters
|
@@ -94,6 +94,91 @@ module Coinbase::Client
|
|
94
94
|
return data, status_code, headers
|
95
95
|
end
|
96
96
|
|
97
|
+
# Get address balance history for asset
|
98
|
+
# List the historical balance of an asset in a specific address.
|
99
|
+
# @param network_id [String] The ID of the blockchain network
|
100
|
+
# @param address_id [String] The ID of the address to fetch the historical balance for.
|
101
|
+
# @param asset_id [String] The symbol of the asset to fetch the historical balance for.
|
102
|
+
# @param [Hash] opts the optional parameters
|
103
|
+
# @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
|
104
|
+
# @option opts [String] :page A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
|
105
|
+
# @return [AddressHistoricalBalanceList]
|
106
|
+
def list_address_historical_balance(network_id, address_id, asset_id, opts = {})
|
107
|
+
data, _status_code, _headers = list_address_historical_balance_with_http_info(network_id, address_id, asset_id, opts)
|
108
|
+
data
|
109
|
+
end
|
110
|
+
|
111
|
+
# Get address balance history for asset
|
112
|
+
# List the historical balance of an asset in a specific address.
|
113
|
+
# @param network_id [String] The ID of the blockchain network
|
114
|
+
# @param address_id [String] The ID of the address to fetch the historical balance for.
|
115
|
+
# @param asset_id [String] The symbol of the asset to fetch the historical balance for.
|
116
|
+
# @param [Hash] opts the optional parameters
|
117
|
+
# @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
|
118
|
+
# @option opts [String] :page A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
|
119
|
+
# @return [Array<(AddressHistoricalBalanceList, Integer, Hash)>] AddressHistoricalBalanceList data, response status code and response headers
|
120
|
+
def list_address_historical_balance_with_http_info(network_id, address_id, asset_id, opts = {})
|
121
|
+
if @api_client.config.debugging
|
122
|
+
@api_client.config.logger.debug 'Calling API: ExternalAddressesApi.list_address_historical_balance ...'
|
123
|
+
end
|
124
|
+
# verify the required parameter 'network_id' is set
|
125
|
+
if @api_client.config.client_side_validation && network_id.nil?
|
126
|
+
fail ArgumentError, "Missing the required parameter 'network_id' when calling ExternalAddressesApi.list_address_historical_balance"
|
127
|
+
end
|
128
|
+
# verify the required parameter 'address_id' is set
|
129
|
+
if @api_client.config.client_side_validation && address_id.nil?
|
130
|
+
fail ArgumentError, "Missing the required parameter 'address_id' when calling ExternalAddressesApi.list_address_historical_balance"
|
131
|
+
end
|
132
|
+
# verify the required parameter 'asset_id' is set
|
133
|
+
if @api_client.config.client_side_validation && asset_id.nil?
|
134
|
+
fail ArgumentError, "Missing the required parameter 'asset_id' when calling ExternalAddressesApi.list_address_historical_balance"
|
135
|
+
end
|
136
|
+
if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'].to_s.length > 5000
|
137
|
+
fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ExternalAddressesApi.list_address_historical_balance, the character length must be smaller than or equal to 5000.'
|
138
|
+
end
|
139
|
+
|
140
|
+
# resource path
|
141
|
+
local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/balance_history/{asset_id}'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'asset_id' + '}', CGI.escape(asset_id.to_s))
|
142
|
+
|
143
|
+
# query parameters
|
144
|
+
query_params = opts[:query_params] || {}
|
145
|
+
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
|
146
|
+
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
147
|
+
|
148
|
+
# header parameters
|
149
|
+
header_params = opts[:header_params] || {}
|
150
|
+
# HTTP header 'Accept' (if needed)
|
151
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
152
|
+
|
153
|
+
# form parameters
|
154
|
+
form_params = opts[:form_params] || {}
|
155
|
+
|
156
|
+
# http body (model)
|
157
|
+
post_body = opts[:debug_body]
|
158
|
+
|
159
|
+
# return_type
|
160
|
+
return_type = opts[:debug_return_type] || 'AddressHistoricalBalanceList'
|
161
|
+
|
162
|
+
# auth_names
|
163
|
+
auth_names = opts[:debug_auth_names] || []
|
164
|
+
|
165
|
+
new_options = opts.merge(
|
166
|
+
:operation => :"ExternalAddressesApi.list_address_historical_balance",
|
167
|
+
:header_params => header_params,
|
168
|
+
:query_params => query_params,
|
169
|
+
:form_params => form_params,
|
170
|
+
:body => post_body,
|
171
|
+
:auth_names => auth_names,
|
172
|
+
:return_type => return_type
|
173
|
+
)
|
174
|
+
|
175
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
176
|
+
if @api_client.config.debugging
|
177
|
+
@api_client.config.logger.debug "API called: ExternalAddressesApi#list_address_historical_balance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
178
|
+
end
|
179
|
+
return data, status_code, headers
|
180
|
+
end
|
181
|
+
|
97
182
|
# Get the balances of an external address
|
98
183
|
# List all of the balances of an external address
|
99
184
|
# @param network_id [String] The ID of the blockchain network
|
@@ -0,0 +1,85 @@
|
|
1
|
+
=begin
|
2
|
+
#Coinbase Platform API
|
3
|
+
|
4
|
+
#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 0.0.1-alpha
|
7
|
+
Contact: yuga.cohler@coinbase.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.7.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module Coinbase::Client
|
16
|
+
class NetworksApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# Get network by ID
|
23
|
+
# Get network
|
24
|
+
# @param network_id [String] The ID of the network to fetch.
|
25
|
+
# @param [Hash] opts the optional parameters
|
26
|
+
# @return [Network]
|
27
|
+
def get_network(network_id, opts = {})
|
28
|
+
data, _status_code, _headers = get_network_with_http_info(network_id, opts)
|
29
|
+
data
|
30
|
+
end
|
31
|
+
|
32
|
+
# Get network by ID
|
33
|
+
# Get network
|
34
|
+
# @param network_id [String] The ID of the network to fetch.
|
35
|
+
# @param [Hash] opts the optional parameters
|
36
|
+
# @return [Array<(Network, Integer, Hash)>] Network data, response status code and response headers
|
37
|
+
def get_network_with_http_info(network_id, opts = {})
|
38
|
+
if @api_client.config.debugging
|
39
|
+
@api_client.config.logger.debug 'Calling API: NetworksApi.get_network ...'
|
40
|
+
end
|
41
|
+
# verify the required parameter 'network_id' is set
|
42
|
+
if @api_client.config.client_side_validation && network_id.nil?
|
43
|
+
fail ArgumentError, "Missing the required parameter 'network_id' when calling NetworksApi.get_network"
|
44
|
+
end
|
45
|
+
# resource path
|
46
|
+
local_var_path = '/v1/networks/{network_id}'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s))
|
47
|
+
|
48
|
+
# query parameters
|
49
|
+
query_params = opts[:query_params] || {}
|
50
|
+
|
51
|
+
# header parameters
|
52
|
+
header_params = opts[:header_params] || {}
|
53
|
+
# HTTP header 'Accept' (if needed)
|
54
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
55
|
+
|
56
|
+
# form parameters
|
57
|
+
form_params = opts[:form_params] || {}
|
58
|
+
|
59
|
+
# http body (model)
|
60
|
+
post_body = opts[:debug_body]
|
61
|
+
|
62
|
+
# return_type
|
63
|
+
return_type = opts[:debug_return_type] || 'Network'
|
64
|
+
|
65
|
+
# auth_names
|
66
|
+
auth_names = opts[:debug_auth_names] || []
|
67
|
+
|
68
|
+
new_options = opts.merge(
|
69
|
+
:operation => :"NetworksApi.get_network",
|
70
|
+
:header_params => header_params,
|
71
|
+
:query_params => query_params,
|
72
|
+
:form_params => form_params,
|
73
|
+
:body => post_body,
|
74
|
+
:auth_names => auth_names,
|
75
|
+
:return_type => return_type
|
76
|
+
)
|
77
|
+
|
78
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
79
|
+
if @api_client.config.debugging
|
80
|
+
@api_client.config.logger.debug "API called: NetworksApi#get_network\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
81
|
+
end
|
82
|
+
return data, status_code, headers
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|