@taquito/rpc 24.2.0 → 24.3.0-beta.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.
- package/dist/lib/rpc-client-interface.js +1 -0
- package/dist/lib/rpc-client-modules/rpc-cache.js +703 -820
- package/dist/lib/taquito-rpc.js +517 -615
- package/dist/lib/version.js +2 -2
- package/dist/taquito-rpc.es6.js +1230 -1444
- package/dist/taquito-rpc.es6.js.map +1 -1
- package/dist/taquito-rpc.umd.js +2317 -2531
- package/dist/taquito-rpc.umd.js.map +1 -1
- package/dist/types/rpc-client-interface.d.ts +3 -1
- package/dist/types/rpc-client-modules/rpc-cache.d.ts +68 -63
- package/dist/types/taquito-rpc.d.ts +72 -62
- package/dist/types/types.d.ts +10 -0
- package/package.json +24 -11
- package/LICENSE +0 -202
package/dist/taquito-rpc.es6.js
CHANGED
|
@@ -3,50 +3,6 @@ import BigNumber from 'bignumber.js';
|
|
|
3
3
|
import { validateAddress, ValidationResult, validateContractAddress, validateProtocol, InvalidProtocolHashError } from '@taquito/utils';
|
|
4
4
|
import { InvalidAddressError, InvalidContractAddressError } from '@taquito/core';
|
|
5
5
|
|
|
6
|
-
/******************************************************************************
|
|
7
|
-
Copyright (c) Microsoft Corporation.
|
|
8
|
-
|
|
9
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
purpose with or without fee is hereby granted.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
-
***************************************************************************** */
|
|
20
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function __rest(s, e) {
|
|
24
|
-
var t = {};
|
|
25
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
26
|
-
t[p] = s[p];
|
|
27
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
28
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
29
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
30
|
-
t[p[i]] = s[p[i]];
|
|
31
|
-
}
|
|
32
|
-
return t;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
46
|
-
var e = new Error(message);
|
|
47
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
6
|
const defaultChain = 'main';
|
|
51
7
|
const defaultRPCOptions = { block: 'head' };
|
|
52
8
|
var RPCMethodName;
|
|
@@ -101,6 +57,7 @@ var RPCMethodName;
|
|
|
101
57
|
RPCMethodName["GET_ALL_TICKET_BALANCES"] = "getAllTicketBalances";
|
|
102
58
|
RPCMethodName["GET_ADAPTIVE_ISSUANCE_LAUNCH_CYCLE"] = "getAdaptiveIssuanceLaunchCycle";
|
|
103
59
|
RPCMethodName["GET_PENDING_OPERATIONS"] = "getPendingOperations";
|
|
60
|
+
RPCMethodName["GET_MEMPOOL_FILTER"] = "getMempoolFilter";
|
|
104
61
|
RPCMethodName["GET_DESTINATION_INDEX"] = "getDestinationIndex";
|
|
105
62
|
})(RPCMethodName || (RPCMethodName = {}));
|
|
106
63
|
|
|
@@ -135,7 +92,7 @@ function castToBigNumber(data, keys) {
|
|
|
135
92
|
|
|
136
93
|
const defaultTtl = 1000;
|
|
137
94
|
/***
|
|
138
|
-
*
|
|
95
|
+
* RpcClientCache acts as a decorator over the RpcClient instance by caching responses for the period defined by the ttl.
|
|
139
96
|
*/
|
|
140
97
|
class RpcClientCache {
|
|
141
98
|
/**
|
|
@@ -154,7 +111,7 @@ class RpcClientCache {
|
|
|
154
111
|
return this._cache;
|
|
155
112
|
}
|
|
156
113
|
/**
|
|
157
|
-
*
|
|
114
|
+
* Remove all the data in the cache.
|
|
158
115
|
*
|
|
159
116
|
*/
|
|
160
117
|
deleteAllCachedData() {
|
|
@@ -205,819 +162,737 @@ class RpcClientCache {
|
|
|
205
162
|
}
|
|
206
163
|
/**
|
|
207
164
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
208
|
-
*
|
|
165
|
+
* Get the block's hash, its unique identifier.
|
|
209
166
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-hash
|
|
210
167
|
*/
|
|
211
|
-
getBlockHash() {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
});
|
|
168
|
+
async getBlockHash({ block } = defaultRPCOptions) {
|
|
169
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BLOCK_HASH, [
|
|
170
|
+
block,
|
|
171
|
+
]);
|
|
172
|
+
if (this.has(key)) {
|
|
173
|
+
return this.get(key);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const response = this.rpcClient.getBlockHash({ block });
|
|
177
|
+
this.put(key, response);
|
|
178
|
+
return response;
|
|
179
|
+
}
|
|
225
180
|
}
|
|
226
181
|
/**
|
|
227
182
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
228
|
-
*
|
|
183
|
+
* List the ancestors of the given block which, if referred to as the branch in an operation header, are recent enough for that operation to be included in the current block.
|
|
229
184
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-live-blocks
|
|
230
185
|
*/
|
|
231
|
-
getLiveBlocks() {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
});
|
|
186
|
+
async getLiveBlocks({ block } = defaultRPCOptions) {
|
|
187
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_LIVE_BLOCKS, [
|
|
188
|
+
block,
|
|
189
|
+
]);
|
|
190
|
+
if (this.has(key)) {
|
|
191
|
+
return this.get(key);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const response = this.rpcClient.getLiveBlocks({ block });
|
|
195
|
+
this.put(key, response);
|
|
196
|
+
return response;
|
|
197
|
+
}
|
|
245
198
|
}
|
|
246
199
|
/**
|
|
247
200
|
* @param address address from which we want to retrieve the spendable balance
|
|
248
201
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
249
|
-
*
|
|
202
|
+
* The spendable balance of a contract (in mutez), also known as liquid balance. Corresponds to tez owned by the contract that are neither staked, nor in unstaked requests, nor in frozen bonds. Identical to the 'spendable' RPC.
|
|
250
203
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-balance
|
|
251
204
|
*/
|
|
252
|
-
getBalance(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
});
|
|
205
|
+
async getBalance(address, { block } = defaultRPCOptions) {
|
|
206
|
+
this.validateAddress(address);
|
|
207
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BALANCE, [
|
|
208
|
+
block,
|
|
209
|
+
address,
|
|
210
|
+
]);
|
|
211
|
+
if (this.has(key)) {
|
|
212
|
+
return this.get(key);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
const response = this.rpcClient.getBalance(address, { block });
|
|
216
|
+
this.put(key, response);
|
|
217
|
+
return response;
|
|
218
|
+
}
|
|
268
219
|
}
|
|
269
220
|
/**
|
|
270
221
|
* @param address address from which we want to retrieve the balance
|
|
271
222
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
272
|
-
*
|
|
273
|
-
*/
|
|
274
|
-
getSpendable(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
});
|
|
223
|
+
* The spendable balance of a contract (in mutez), also known as liquid balance. Corresponds to tez owned by the contract that are neither staked, nor in unstaked requests, nor in frozen bonds. Identical to the 'balance' RPC.
|
|
224
|
+
*/
|
|
225
|
+
async getSpendable(address, { block } = defaultRPCOptions) {
|
|
226
|
+
this.validateAddress(address);
|
|
227
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_SPENDABLE, [
|
|
228
|
+
block,
|
|
229
|
+
address,
|
|
230
|
+
]);
|
|
231
|
+
if (this.has(key)) {
|
|
232
|
+
return this.get(key);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const response = this.rpcClient.getSpendable(address, { block });
|
|
236
|
+
this.put(key, response);
|
|
237
|
+
return response;
|
|
238
|
+
}
|
|
290
239
|
}
|
|
291
240
|
/**
|
|
292
241
|
* @param address address from which we want to retrieve balance and frozen bonds
|
|
293
242
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
294
|
-
*
|
|
243
|
+
* The sum (in mutez) of the spendable balance and frozen bonds of a contract. Corresponds to the contract's full balance from which staked funds and unstake requests have been excluded. Identical to the 'spendable_and_frozen_bonds' RPC.
|
|
295
244
|
*/
|
|
296
|
-
getBalanceAndFrozenBonds(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
});
|
|
245
|
+
async getBalanceAndFrozenBonds(address, { block } = defaultRPCOptions) {
|
|
246
|
+
this.validateAddress(address);
|
|
247
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BALANCE_AND_FROZEN_BONDS, [block, address]);
|
|
248
|
+
if (this.has(key)) {
|
|
249
|
+
return this.get(key);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
const response = this.rpcClient.getBalanceAndFrozenBonds(address, { block });
|
|
253
|
+
this.put(key, response);
|
|
254
|
+
return response;
|
|
255
|
+
}
|
|
309
256
|
}
|
|
310
257
|
/**
|
|
311
258
|
* @param address address from which we want to retrieve spendable and frozen bonds
|
|
312
259
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
313
|
-
*
|
|
260
|
+
* The sum (in mutez) of the spendable balance and frozen bonds of a contract. Corresponds to the contract's full balance from which staked funds and unstake requests have been excluded. Identical to the 'balance_and_frozen_bonds' RPC.
|
|
314
261
|
*/
|
|
315
|
-
getSpendableAndFrozenBonds(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
});
|
|
262
|
+
async getSpendableAndFrozenBonds(address, { block } = defaultRPCOptions) {
|
|
263
|
+
this.validateAddress(address);
|
|
264
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_SPENDABLE_AND_FROZEN_BONDS, [block, address]);
|
|
265
|
+
if (this.has(key)) {
|
|
266
|
+
return this.get(key);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
const response = this.rpcClient.getSpendableAndFrozenBonds(address, { block });
|
|
270
|
+
this.put(key, response);
|
|
271
|
+
return response;
|
|
272
|
+
}
|
|
328
273
|
}
|
|
329
274
|
/**
|
|
330
275
|
* @param address address from which we want to retrieve the full balance
|
|
331
276
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
332
|
-
*
|
|
277
|
+
* Access the full balance of a contract, including frozen bonds and stake.
|
|
333
278
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-full-balance
|
|
334
279
|
*/
|
|
335
|
-
getFullBalance(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
});
|
|
280
|
+
async getFullBalance(address, { block } = defaultRPCOptions) {
|
|
281
|
+
this.validateAddress(address);
|
|
282
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_FULL_BALANCE, [
|
|
283
|
+
block,
|
|
284
|
+
address,
|
|
285
|
+
]);
|
|
286
|
+
if (this.has(key)) {
|
|
287
|
+
return this.get(key);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
const response = this.rpcClient.getFullBalance(address, { block });
|
|
291
|
+
this.put(key, response);
|
|
292
|
+
return response;
|
|
293
|
+
}
|
|
351
294
|
}
|
|
352
295
|
/**
|
|
353
296
|
* @param address address from which we want to retrieve the staked balance
|
|
354
297
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
355
|
-
*
|
|
298
|
+
* Access the staked balance of a contract. Returns None if the contract is originated, or neither delegated nor a delegate.
|
|
356
299
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-staked-balance
|
|
357
300
|
*/
|
|
358
|
-
getStakedBalance(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
});
|
|
301
|
+
async getStakedBalance(address, { block } = defaultRPCOptions) {
|
|
302
|
+
this.validateAddress(address);
|
|
303
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_STAKED_BALANCE, [
|
|
304
|
+
block,
|
|
305
|
+
address,
|
|
306
|
+
]);
|
|
307
|
+
if (this.has(key)) {
|
|
308
|
+
return this.get(key);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
const response = this.rpcClient.getStakedBalance(address, { block });
|
|
312
|
+
this.put(key, response);
|
|
313
|
+
return response;
|
|
314
|
+
}
|
|
374
315
|
}
|
|
375
316
|
/**
|
|
376
317
|
* @param address address from which we want to retrieve the unstaked finalizable balance
|
|
377
318
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
378
|
-
*
|
|
319
|
+
* Access the balance of a contract that was requested for an unstake operation, and is no longer frozen, which means it will appear in the spendable balance of the contract after any stake/unstake/finalize_unstake operation. Returns None if the contract is originated.
|
|
379
320
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstaked-finalizable-balance
|
|
380
321
|
*/
|
|
381
|
-
getUnstakedFinalizableBalance(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
});
|
|
322
|
+
async getUnstakedFinalizableBalance(address, { block } = defaultRPCOptions) {
|
|
323
|
+
this.validateAddress(address);
|
|
324
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_UNSTAKED_FINALIZABLE_BALANCE, [block, address]);
|
|
325
|
+
if (this.has(key)) {
|
|
326
|
+
return this.get(key);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
const response = this.rpcClient.getUnstakedFinalizableBalance(address, { block });
|
|
330
|
+
this.put(key, response);
|
|
331
|
+
return response;
|
|
332
|
+
}
|
|
394
333
|
}
|
|
395
334
|
/**
|
|
396
335
|
* @param address address from which we want to retrieve the unstaked frozen balance
|
|
397
336
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
398
|
-
*
|
|
337
|
+
* Access the balance of a contract that was requested for an unstake operation, but is still frozen for the duration of the slashing period. Returns None if the contract is originated.
|
|
399
338
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstaked-frozen-balance
|
|
400
339
|
*/
|
|
401
|
-
getUnstakedFrozenBalance(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
});
|
|
340
|
+
async getUnstakedFrozenBalance(address, { block } = defaultRPCOptions) {
|
|
341
|
+
this.validateAddress(address);
|
|
342
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_UNSTAKED_FROZEN_BALANCE, [block, address]);
|
|
343
|
+
if (this.has(key)) {
|
|
344
|
+
return this.get(key);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
const response = this.rpcClient.getUnstakedFrozenBalance(address, { block });
|
|
348
|
+
this.put(key, response);
|
|
349
|
+
return response;
|
|
350
|
+
}
|
|
414
351
|
}
|
|
415
352
|
/**
|
|
416
353
|
* @param address address from which we want to retrieve the unstake requests
|
|
417
354
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
418
|
-
*
|
|
355
|
+
* Access the unstake requests of the contract. The requests that appear in the finalizable field can be finalized, which means that the contract can transfer these (no longer frozen) funds to their spendable balance with a [finalize_unstake] operation call. Returns null if there is no unstake request pending.
|
|
419
356
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstake-requests
|
|
420
357
|
*/
|
|
421
|
-
getUnstakeRequests(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
});
|
|
358
|
+
async getUnstakeRequests(address, { block } = defaultRPCOptions) {
|
|
359
|
+
this.validateAddress(address);
|
|
360
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_UNSTAKE_REQUESTS, [block, address]);
|
|
361
|
+
if (this.has(key)) {
|
|
362
|
+
return this.get(key);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
const response = this.rpcClient.getUnstakeRequests(address, { block });
|
|
366
|
+
this.put(key, response);
|
|
367
|
+
return response;
|
|
368
|
+
}
|
|
434
369
|
}
|
|
435
370
|
/**
|
|
436
371
|
* @param address contract address from which we want to retrieve the storage
|
|
437
372
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
438
|
-
*
|
|
373
|
+
* Access the data of the contract.
|
|
439
374
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-storage
|
|
440
375
|
*/
|
|
441
|
-
getStorage(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
});
|
|
376
|
+
async getStorage(address, { block } = defaultRPCOptions) {
|
|
377
|
+
this.validateContract(address);
|
|
378
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_STORAGE, [
|
|
379
|
+
block,
|
|
380
|
+
address,
|
|
381
|
+
]);
|
|
382
|
+
if (this.has(key)) {
|
|
383
|
+
return this.get(key);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
const response = this.rpcClient.getStorage(address, { block });
|
|
387
|
+
this.put(key, response);
|
|
388
|
+
return response;
|
|
389
|
+
}
|
|
457
390
|
}
|
|
458
391
|
/**
|
|
459
392
|
* @param address contract address from which we want to retrieve the script
|
|
460
393
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
461
|
-
*
|
|
394
|
+
* Access the code and data of the contract.
|
|
462
395
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-script
|
|
463
396
|
*/
|
|
464
|
-
getScript(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
});
|
|
397
|
+
async getScript(address, { block } = defaultRPCOptions) {
|
|
398
|
+
this.validateContract(address);
|
|
399
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_SCRIPT, [
|
|
400
|
+
block,
|
|
401
|
+
address,
|
|
402
|
+
]);
|
|
403
|
+
if (this.has(key)) {
|
|
404
|
+
return this.get(key);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
const response = this.rpcClient.getScript(address, { block });
|
|
408
|
+
this.put(key, response);
|
|
409
|
+
return response;
|
|
410
|
+
}
|
|
480
411
|
}
|
|
481
412
|
/**
|
|
482
413
|
* @param address contract address from which we want to retrieve the script
|
|
483
414
|
* @param unparsingMode default is { unparsing_mode: "Readable" }
|
|
484
415
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
485
|
-
*
|
|
416
|
+
* Access the script of the contract and normalize it using the requested unparsing mode.
|
|
486
417
|
*/
|
|
487
|
-
getNormalizedScript(
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
});
|
|
418
|
+
async getNormalizedScript(address, unparsingMode = { unparsing_mode: 'Readable' }, { block } = defaultRPCOptions) {
|
|
419
|
+
this.validateContract(address);
|
|
420
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_NORMALIZED_SCRIPT, [block, address], unparsingMode);
|
|
421
|
+
if (this.has(key)) {
|
|
422
|
+
return this.get(key);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
const response = this.rpcClient.getNormalizedScript(address, unparsingMode, { block });
|
|
426
|
+
this.put(key, response);
|
|
427
|
+
return response;
|
|
428
|
+
}
|
|
500
429
|
}
|
|
501
430
|
/**
|
|
502
431
|
* @param address contract address from which we want to retrieve
|
|
503
432
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
504
|
-
*
|
|
433
|
+
* Access the complete status of a contract.
|
|
505
434
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id
|
|
506
435
|
*/
|
|
507
|
-
getContract(
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
});
|
|
436
|
+
async getContract(address, { block } = defaultRPCOptions) {
|
|
437
|
+
this.validateAddress(address);
|
|
438
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_CONTRACT, [
|
|
439
|
+
block,
|
|
440
|
+
address,
|
|
441
|
+
]);
|
|
442
|
+
if (this.has(key)) {
|
|
443
|
+
return this.get(key);
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
const response = this.rpcClient.getContract(address, { block });
|
|
447
|
+
this.put(key, response);
|
|
448
|
+
return response;
|
|
449
|
+
}
|
|
523
450
|
}
|
|
524
451
|
/**
|
|
525
452
|
* @param address contract address from which we want to retrieve the manager
|
|
526
453
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
527
|
-
*
|
|
454
|
+
* Access the manager of an implicit contract
|
|
528
455
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-manager-key
|
|
529
456
|
*/
|
|
530
|
-
getManagerKey(
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
});
|
|
457
|
+
async getManagerKey(address, { block } = defaultRPCOptions) {
|
|
458
|
+
this.validateAddress(address);
|
|
459
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_MANAGER_KEY, [
|
|
460
|
+
block,
|
|
461
|
+
address,
|
|
462
|
+
]);
|
|
463
|
+
if (this.has(key)) {
|
|
464
|
+
return this.get(key);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
const response = this.rpcClient.getManagerKey(address, { block });
|
|
468
|
+
this.put(key, response);
|
|
469
|
+
return response;
|
|
470
|
+
}
|
|
546
471
|
}
|
|
547
472
|
/**
|
|
548
473
|
* @param address contract address from which we want to retrieve the delegate (baker)
|
|
549
474
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
550
|
-
*
|
|
475
|
+
* Access the delegate of a contract, if any
|
|
551
476
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-delegate
|
|
552
477
|
*/
|
|
553
|
-
getDelegate(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
568
|
-
});
|
|
478
|
+
async getDelegate(address, { block } = defaultRPCOptions) {
|
|
479
|
+
this.validateAddress(address);
|
|
480
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_DELEGATE, [
|
|
481
|
+
block,
|
|
482
|
+
address,
|
|
483
|
+
]);
|
|
484
|
+
if (this.has(key)) {
|
|
485
|
+
return this.get(key);
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
const response = this.rpcClient.getDelegate(address, { block });
|
|
489
|
+
this.put(key, response);
|
|
490
|
+
return response;
|
|
491
|
+
}
|
|
569
492
|
}
|
|
570
493
|
/**
|
|
571
494
|
* @param id Big Map ID
|
|
572
495
|
* @param expr Expression hash to query (A b58check encoded Blake2b hash of the expression (The expression can be packed using the pack_data method))
|
|
573
496
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
574
|
-
*
|
|
497
|
+
* Access the value associated with a key in a big map.
|
|
575
498
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-big-maps-big-map-id-script-expr
|
|
576
499
|
*/
|
|
577
|
-
getBigMapExpr(
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
});
|
|
500
|
+
async getBigMapExpr(id, expr, { block } = defaultRPCOptions) {
|
|
501
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BIG_MAP_EXPR, [
|
|
502
|
+
block,
|
|
503
|
+
id,
|
|
504
|
+
expr,
|
|
505
|
+
]);
|
|
506
|
+
if (this.has(key)) {
|
|
507
|
+
return this.get(key);
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
const response = this.rpcClient.getBigMapExpr(id, expr, { block });
|
|
511
|
+
this.put(key, response);
|
|
512
|
+
return response;
|
|
513
|
+
}
|
|
593
514
|
}
|
|
594
515
|
/**
|
|
595
516
|
* @param args contains optional query arguments (active, inactive, with_minimal_stake, without_minimal_stake)
|
|
596
517
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
597
|
-
*
|
|
518
|
+
* Lists all registered delegates by default with query arguments to filter unneeded values.
|
|
598
519
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh
|
|
599
520
|
*/
|
|
600
|
-
getAllDelegates() {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
});
|
|
521
|
+
async getAllDelegates(args = {}, { block } = defaultRPCOptions) {
|
|
522
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_ALL_DELEGATES, [
|
|
523
|
+
block,
|
|
524
|
+
args,
|
|
525
|
+
]);
|
|
526
|
+
if (this.has(key)) {
|
|
527
|
+
return this.get(key);
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
const response = this.rpcClient.getAllDelegates(args, { block });
|
|
531
|
+
this.put(key, response);
|
|
532
|
+
return response;
|
|
533
|
+
}
|
|
615
534
|
}
|
|
616
535
|
/**
|
|
617
536
|
* @param address delegate address which we want to retrieve
|
|
618
537
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
619
|
-
*
|
|
538
|
+
* Everything about a delegate
|
|
620
539
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh
|
|
621
540
|
*/
|
|
622
|
-
getDelegates(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
});
|
|
541
|
+
async getDelegates(address, { block } = defaultRPCOptions) {
|
|
542
|
+
this.validateAddress(address);
|
|
543
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_DELEGATES, [
|
|
544
|
+
block,
|
|
545
|
+
address,
|
|
546
|
+
]);
|
|
547
|
+
if (this.has(key)) {
|
|
548
|
+
return this.get(key);
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
const response = this.rpcClient.getDelegates(address, { block });
|
|
552
|
+
this.put(key, response);
|
|
553
|
+
return response;
|
|
554
|
+
}
|
|
638
555
|
}
|
|
639
556
|
/**
|
|
640
557
|
* @param address delegate address which we want to retrieve
|
|
641
558
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
642
|
-
*
|
|
559
|
+
* Returns the delegate info (e.g. voting power) found in the listings of the current voting period
|
|
643
560
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-voting-info
|
|
644
561
|
*/
|
|
645
|
-
getVotingInfo(
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
});
|
|
562
|
+
async getVotingInfo(address, { block } = defaultRPCOptions) {
|
|
563
|
+
this.validateAddress(address);
|
|
564
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_VOTING_INFO, [
|
|
565
|
+
block,
|
|
566
|
+
address,
|
|
567
|
+
]);
|
|
568
|
+
if (this.has(key)) {
|
|
569
|
+
return this.get(key);
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
const response = this.rpcClient.getVotingInfo(address, { block });
|
|
573
|
+
this.put(key, response);
|
|
574
|
+
return response;
|
|
575
|
+
}
|
|
661
576
|
}
|
|
662
577
|
/**
|
|
663
578
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
664
|
-
*
|
|
579
|
+
* All constants
|
|
665
580
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-constants
|
|
666
581
|
*/
|
|
667
|
-
getConstants() {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
});
|
|
582
|
+
async getConstants({ block } = defaultRPCOptions) {
|
|
583
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_CONSTANTS, [
|
|
584
|
+
block,
|
|
585
|
+
]);
|
|
586
|
+
if (this.has(key)) {
|
|
587
|
+
return this.get(key);
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
const response = this.rpcClient.getConstants({ block });
|
|
591
|
+
this.put(key, response);
|
|
592
|
+
return response;
|
|
593
|
+
}
|
|
681
594
|
}
|
|
682
595
|
/**
|
|
683
596
|
* @param options contains generic configuration for rpc calls to specified block (default to head) and version.
|
|
684
|
-
*
|
|
597
|
+
* All the information about a block
|
|
685
598
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id
|
|
686
599
|
* @example getBlock() will default to `/main/chains/block/head?version=1`
|
|
687
600
|
* @example getBlock({ block: 'head~2') will return an offset of 2 from head blocks
|
|
688
601
|
* @example getBlock({ block: 'BL8fTiWcSxWCjiMVnDkbh6EuhqVPZzgWheJ2dqwrxYRm9AephXh~2' }) will return an offset of 2 blocks from given block hash..
|
|
689
602
|
*/
|
|
690
|
-
getBlock() {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
}
|
|
701
|
-
});
|
|
603
|
+
async getBlock({ block } = defaultRPCOptions) {
|
|
604
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BLOCK, [block]);
|
|
605
|
+
if (this.has(key)) {
|
|
606
|
+
return this.get(key);
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
const response = this.rpcClient.getBlock({ block });
|
|
610
|
+
this.put(key, response);
|
|
611
|
+
return response;
|
|
612
|
+
}
|
|
702
613
|
}
|
|
703
614
|
/**
|
|
704
615
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
705
|
-
*
|
|
616
|
+
* The whole block header
|
|
706
617
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-header
|
|
707
618
|
*/
|
|
708
|
-
getBlockHeader() {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
});
|
|
619
|
+
async getBlockHeader({ block } = defaultRPCOptions) {
|
|
620
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BLOCK_HEADER, [
|
|
621
|
+
block,
|
|
622
|
+
]);
|
|
623
|
+
if (this.has(key)) {
|
|
624
|
+
return this.get(key);
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
const response = this.rpcClient.getBlockHeader({ block });
|
|
628
|
+
this.put(key, response);
|
|
629
|
+
return response;
|
|
630
|
+
}
|
|
722
631
|
}
|
|
723
632
|
/**
|
|
724
633
|
* @param options contains generic configuration for rpc calls to specified block (default to head) and version
|
|
725
|
-
*
|
|
634
|
+
* All the metadata associated to the block
|
|
726
635
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-metadata
|
|
727
636
|
*/
|
|
728
|
-
getBlockMetadata() {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
});
|
|
637
|
+
async getBlockMetadata({ block } = defaultRPCOptions) {
|
|
638
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BLOCK_METADATA, [
|
|
639
|
+
block,
|
|
640
|
+
]);
|
|
641
|
+
if (this.has(key)) {
|
|
642
|
+
return this.get(key);
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
const response = this.rpcClient.getBlockMetadata({ block });
|
|
646
|
+
this.put(key, response);
|
|
647
|
+
return response;
|
|
648
|
+
}
|
|
742
649
|
}
|
|
743
650
|
/**
|
|
744
651
|
* @param args contains optional query arguments (level, cycle, delegate, consensus_key, and max_round)
|
|
745
652
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
746
|
-
*
|
|
653
|
+
* Retrieves the list of delegates allowed to bake a block.
|
|
747
654
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
748
655
|
*/
|
|
749
|
-
getBakingRights() {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
});
|
|
656
|
+
async getBakingRights(args = {}, { block } = defaultRPCOptions) {
|
|
657
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BAKING_RIGHTS, [
|
|
658
|
+
block,
|
|
659
|
+
args,
|
|
660
|
+
]);
|
|
661
|
+
if (this.has(key)) {
|
|
662
|
+
return this.get(key);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
const response = this.rpcClient.getBakingRights(args, { block });
|
|
666
|
+
this.put(key, response);
|
|
667
|
+
return response;
|
|
668
|
+
}
|
|
764
669
|
}
|
|
765
670
|
/**
|
|
766
671
|
* @param args contains optional query arguments (level, cycle, delegate, and consensus_key)
|
|
767
672
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
768
|
-
*
|
|
673
|
+
* Retrieves the delegates allowed to attest a block
|
|
769
674
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
770
675
|
*/
|
|
771
|
-
getAttestationRights() {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
});
|
|
676
|
+
async getAttestationRights(args = {}, { block } = defaultRPCOptions) {
|
|
677
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_ATTESTATION_RIGHTS, [block, args]);
|
|
678
|
+
if (this.has(key)) {
|
|
679
|
+
return this.get(key);
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
const response = this.rpcClient.getAttestationRights(args, { block });
|
|
683
|
+
this.put(key, response);
|
|
684
|
+
return response;
|
|
685
|
+
}
|
|
783
686
|
}
|
|
784
687
|
/**
|
|
785
688
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
786
|
-
*
|
|
689
|
+
* Ballots casted so far during a voting period
|
|
787
690
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-ballot-list
|
|
788
691
|
*/
|
|
789
|
-
getBallotList() {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
});
|
|
692
|
+
async getBallotList({ block } = defaultRPCOptions) {
|
|
693
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BALLOT_LIST, [
|
|
694
|
+
block,
|
|
695
|
+
]);
|
|
696
|
+
if (this.has(key)) {
|
|
697
|
+
return this.get(key);
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
const response = this.rpcClient.getBallotList({ block });
|
|
701
|
+
this.put(key, response);
|
|
702
|
+
return response;
|
|
703
|
+
}
|
|
803
704
|
}
|
|
804
705
|
/**
|
|
805
706
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
806
|
-
*
|
|
707
|
+
* Sum of ballots casted so far during a voting period
|
|
807
708
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-ballots
|
|
808
709
|
*/
|
|
809
|
-
getBallots() {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
}
|
|
820
|
-
});
|
|
710
|
+
async getBallots({ block } = defaultRPCOptions) {
|
|
711
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_BALLOTS, [block]);
|
|
712
|
+
if (this.has(key)) {
|
|
713
|
+
return this.get(key);
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
const response = this.rpcClient.getBallots({ block });
|
|
717
|
+
this.put(key, response);
|
|
718
|
+
return response;
|
|
719
|
+
}
|
|
821
720
|
}
|
|
822
721
|
/**
|
|
823
722
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
824
|
-
*
|
|
723
|
+
* Current proposal under evaluation.
|
|
825
724
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-proposal
|
|
826
725
|
*/
|
|
827
|
-
getCurrentProposal() {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
});
|
|
726
|
+
async getCurrentProposal({ block, } = defaultRPCOptions) {
|
|
727
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_CURRENT_PROPOSAL, [block]);
|
|
728
|
+
if (this.has(key)) {
|
|
729
|
+
return this.get(key);
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
const response = this.rpcClient.getCurrentProposal({ block });
|
|
733
|
+
this.put(key, response);
|
|
734
|
+
return response;
|
|
735
|
+
}
|
|
839
736
|
}
|
|
840
737
|
/**
|
|
841
738
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
842
|
-
*
|
|
739
|
+
* Current expected quorum.
|
|
843
740
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-quorum
|
|
844
741
|
*/
|
|
845
|
-
getCurrentQuorum() {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
});
|
|
742
|
+
async getCurrentQuorum({ block, } = defaultRPCOptions) {
|
|
743
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_CURRENT_QUORUM, [
|
|
744
|
+
block,
|
|
745
|
+
]);
|
|
746
|
+
if (this.has(key)) {
|
|
747
|
+
return this.get(key);
|
|
748
|
+
}
|
|
749
|
+
else {
|
|
750
|
+
const response = this.rpcClient.getCurrentQuorum({ block });
|
|
751
|
+
this.put(key, response);
|
|
752
|
+
return response;
|
|
753
|
+
}
|
|
859
754
|
}
|
|
860
755
|
/**
|
|
861
756
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
862
|
-
*
|
|
757
|
+
* List of delegates with their voting power
|
|
863
758
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-listings
|
|
864
759
|
*/
|
|
865
|
-
getVotesListings() {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
});
|
|
760
|
+
async getVotesListings({ block, } = defaultRPCOptions) {
|
|
761
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_VOTES_LISTINGS, [
|
|
762
|
+
block,
|
|
763
|
+
]);
|
|
764
|
+
if (this.has(key)) {
|
|
765
|
+
return this.get(key);
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
const response = this.rpcClient.getVotesListings({ block });
|
|
769
|
+
this.put(key, response);
|
|
770
|
+
return response;
|
|
771
|
+
}
|
|
879
772
|
}
|
|
880
773
|
/**
|
|
881
774
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
882
|
-
*
|
|
775
|
+
* List of proposals with number of supporters
|
|
883
776
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-proposals
|
|
884
777
|
*/
|
|
885
|
-
getProposals() {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
}
|
|
898
|
-
});
|
|
778
|
+
async getProposals({ block } = defaultRPCOptions) {
|
|
779
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_PROPOSALS, [
|
|
780
|
+
block,
|
|
781
|
+
]);
|
|
782
|
+
if (this.has(key)) {
|
|
783
|
+
return this.get(key);
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
const response = this.rpcClient.getProposals({ block });
|
|
787
|
+
this.put(key, response);
|
|
788
|
+
return response;
|
|
789
|
+
}
|
|
899
790
|
}
|
|
900
791
|
/**
|
|
901
792
|
* @param data operation contents to forge
|
|
902
793
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
903
|
-
*
|
|
794
|
+
* Forge an operation returning the unsigned bytes
|
|
904
795
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
905
796
|
*/
|
|
906
|
-
forgeOperations(
|
|
907
|
-
return
|
|
908
|
-
return this.rpcClient.forgeOperations(data, { block });
|
|
909
|
-
});
|
|
797
|
+
async forgeOperations(data, { block } = defaultRPCOptions) {
|
|
798
|
+
return this.rpcClient.forgeOperations(data, { block });
|
|
910
799
|
}
|
|
911
800
|
/**
|
|
912
801
|
* @param signedOpBytes signed bytes to inject
|
|
913
|
-
*
|
|
802
|
+
* Inject an operation in node and broadcast it and return the ID of the operation
|
|
914
803
|
* @see https://tezos.gitlab.io/shell/rpc.html#post-injection-operation
|
|
915
804
|
*/
|
|
916
|
-
injectOperation(signedOpBytes) {
|
|
917
|
-
return
|
|
918
|
-
return this.rpcClient.injectOperation(signedOpBytes);
|
|
919
|
-
});
|
|
805
|
+
async injectOperation(signedOpBytes) {
|
|
806
|
+
return this.rpcClient.injectOperation(signedOpBytes);
|
|
920
807
|
}
|
|
921
808
|
/**
|
|
922
809
|
* @param ops Operations to apply
|
|
923
810
|
* @param options contains generic configuration for rpc calls to specified block and version
|
|
924
|
-
*
|
|
811
|
+
* Simulate the application of the operations with the context of the given block and return the result of each operation application
|
|
925
812
|
* @see https://tezos.gitlab.io/active/rpc.html#post-block-id-helpers-preapply-operations
|
|
926
813
|
*/
|
|
927
|
-
preapplyOperations(
|
|
928
|
-
return
|
|
929
|
-
return this.rpcClient.preapplyOperations(ops, { block });
|
|
930
|
-
});
|
|
814
|
+
async preapplyOperations(ops, { block } = defaultRPCOptions) {
|
|
815
|
+
return this.rpcClient.preapplyOperations(ops, { block });
|
|
931
816
|
}
|
|
932
817
|
/**
|
|
933
818
|
* @param contract address of the contract we want to get the entrypoints of
|
|
934
819
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
935
|
-
*
|
|
820
|
+
* Return the list of entrypoints of the contract
|
|
936
821
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-entrypoints
|
|
937
|
-
* @version 005_PsBABY5H
|
|
938
|
-
*/
|
|
939
|
-
getEntrypoints(
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
954
|
-
});
|
|
822
|
+
* @remarks version 005_PsBABY5H
|
|
823
|
+
*/
|
|
824
|
+
async getEntrypoints(contract, { block } = defaultRPCOptions) {
|
|
825
|
+
this.validateContract(contract);
|
|
826
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_ENTRYPOINTS, [
|
|
827
|
+
block,
|
|
828
|
+
contract,
|
|
829
|
+
]);
|
|
830
|
+
if (this.has(key)) {
|
|
831
|
+
return this.get(key);
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
const response = this.rpcClient.getEntrypoints(contract, { block });
|
|
835
|
+
this.put(key, response);
|
|
836
|
+
return response;
|
|
837
|
+
}
|
|
955
838
|
}
|
|
956
839
|
/**
|
|
957
840
|
* @param op Operation to simulate
|
|
958
841
|
* @param options contains generic configuration for rpc calls to specified block and version
|
|
959
|
-
*
|
|
842
|
+
* Simulate running an operation at some future moment (based on the number of blocks given in the `latency` argument), and return the operation application result.
|
|
960
843
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
961
844
|
*/
|
|
962
|
-
simulateOperation(
|
|
963
|
-
return
|
|
964
|
-
return this.rpcClient.simulateOperation(op, { block });
|
|
965
|
-
});
|
|
845
|
+
async simulateOperation(op, { block } = defaultRPCOptions) {
|
|
846
|
+
return this.rpcClient.simulateOperation(op, { block });
|
|
966
847
|
}
|
|
967
848
|
/**
|
|
968
849
|
* @param code Code to run
|
|
969
850
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
970
|
-
*
|
|
851
|
+
* Run a Michelson script in the current context
|
|
971
852
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
972
853
|
*/
|
|
973
|
-
runCode(
|
|
974
|
-
return
|
|
975
|
-
return this.rpcClient.runCode(code, { block });
|
|
976
|
-
});
|
|
854
|
+
async runCode(code, { block } = defaultRPCOptions) {
|
|
855
|
+
return this.rpcClient.runCode(code, { block });
|
|
977
856
|
}
|
|
978
857
|
/**
|
|
979
858
|
* @param viewScriptParams Parameters of the script view to run
|
|
980
859
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
981
|
-
*
|
|
860
|
+
* Simulate a call to a michelson view
|
|
982
861
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
983
862
|
*/
|
|
984
|
-
runScriptView(
|
|
985
|
-
return
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
});
|
|
863
|
+
async runScriptView({ unparsing_mode = 'Readable', ...rest }, { block } = defaultRPCOptions) {
|
|
864
|
+
return this.rpcClient.runScriptView({
|
|
865
|
+
unparsing_mode,
|
|
866
|
+
...rest,
|
|
867
|
+
}, { block });
|
|
990
868
|
}
|
|
991
869
|
/**
|
|
992
870
|
* @param viewParams Parameters of the view to run
|
|
993
871
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
994
|
-
*
|
|
872
|
+
* Simulate a call to a view following the TZIP-4 standard.
|
|
995
873
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
996
874
|
*/
|
|
997
|
-
runView(
|
|
998
|
-
return
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
});
|
|
875
|
+
async runView({ unparsing_mode = 'Readable', ...rest }, { block } = defaultRPCOptions) {
|
|
876
|
+
return this.rpcClient.runView({
|
|
877
|
+
unparsing_mode,
|
|
878
|
+
...rest,
|
|
879
|
+
}, { block });
|
|
1003
880
|
}
|
|
1004
|
-
getChainId() {
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
881
|
+
async getChainId() {
|
|
882
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_CHAIN_ID, []);
|
|
883
|
+
if (this.has(key)) {
|
|
884
|
+
return this.get(key);
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
const response = this.rpcClient.getChainId();
|
|
888
|
+
this.put(key, response);
|
|
889
|
+
return response;
|
|
890
|
+
}
|
|
1016
891
|
}
|
|
1017
892
|
/**
|
|
1018
893
|
* @param data Data to pack
|
|
1019
894
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1020
|
-
*
|
|
895
|
+
* Computes the serialized version of a data expression using the same algorithm as script instruction PACK
|
|
1021
896
|
* Note: You should always verify the packed bytes before signing or requesting that they be signed when using the RPC to pack.
|
|
1022
897
|
* This precaution helps protect you and your applications users from RPC nodes that have been compromised.
|
|
1023
898
|
* A node that is operated by a bad actor, or compromised by a bad actor could return a fully formed operation that does not correspond to the input provided to the RPC endpoint.
|
|
@@ -1025,319 +900,304 @@ class RpcClientCache {
|
|
|
1025
900
|
* @example packData({ data: { string: "test" }, type: { prim: "string" } })
|
|
1026
901
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1027
902
|
*/
|
|
1028
|
-
packData(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
}
|
|
1039
|
-
});
|
|
903
|
+
async packData(data, { block } = defaultRPCOptions) {
|
|
904
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.PACK_DATA, [block], data);
|
|
905
|
+
if (this.has(key)) {
|
|
906
|
+
return this.get(key);
|
|
907
|
+
}
|
|
908
|
+
else {
|
|
909
|
+
const response = this.rpcClient.packData(data, { block });
|
|
910
|
+
this.put(key, response);
|
|
911
|
+
return response;
|
|
912
|
+
}
|
|
1040
913
|
}
|
|
1041
914
|
/**
|
|
1042
915
|
*
|
|
1043
|
-
*
|
|
916
|
+
* Return rpc root url
|
|
1044
917
|
*/
|
|
1045
918
|
getRpcUrl() {
|
|
1046
919
|
return this.rpcClient.getRpcUrl();
|
|
1047
920
|
}
|
|
1048
921
|
/**
|
|
1049
922
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1050
|
-
*
|
|
923
|
+
* Returns the voting period (index, kind, starting position) and related information (position, remaining) of the interrogated block
|
|
1051
924
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-period
|
|
1052
925
|
*/
|
|
1053
|
-
getCurrentPeriod() {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
926
|
+
async getCurrentPeriod({ block, } = defaultRPCOptions) {
|
|
927
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_CURRENT_PERIOD, [
|
|
928
|
+
block,
|
|
929
|
+
]);
|
|
930
|
+
if (this.has(key)) {
|
|
931
|
+
return this.get(key);
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
const response = this.rpcClient.getCurrentPeriod({ block });
|
|
935
|
+
this.put(key, response);
|
|
936
|
+
return response;
|
|
937
|
+
}
|
|
1067
938
|
}
|
|
1068
939
|
/**
|
|
1069
940
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1070
|
-
*
|
|
941
|
+
* Returns the voting period (index, kind, starting position) and related information (position, remaining) of the next block.Useful to craft operations that will be valid in the next block
|
|
1071
942
|
* @example getSuccessorPeriod() will default to successor voting period for /main/chains/block/head.
|
|
1072
943
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-successor-period
|
|
1073
944
|
*/
|
|
1074
|
-
getSuccessorPeriod() {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
});
|
|
945
|
+
async getSuccessorPeriod({ block, } = defaultRPCOptions) {
|
|
946
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_SUCCESSOR_PERIOD, [block]);
|
|
947
|
+
if (this.has(key)) {
|
|
948
|
+
return this.get(key);
|
|
949
|
+
}
|
|
950
|
+
else {
|
|
951
|
+
const response = this.rpcClient.getSuccessorPeriod({ block });
|
|
952
|
+
this.put(key, response);
|
|
953
|
+
return response;
|
|
954
|
+
}
|
|
1086
955
|
}
|
|
1087
956
|
/**
|
|
1088
957
|
* @param id Sapling state ID
|
|
1089
958
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1090
|
-
*
|
|
1091
|
-
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-sapling-sapling-state-id-get-diff
|
|
1092
|
-
*/
|
|
1093
|
-
getSaplingDiffById(
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
}
|
|
1104
|
-
});
|
|
959
|
+
* Returns the root and a diff of a state starting from an optional offset which is zero by default
|
|
960
|
+
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-sapling-sapling-state-id-get-diff
|
|
961
|
+
*/
|
|
962
|
+
async getSaplingDiffById(id, { block } = defaultRPCOptions) {
|
|
963
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_SAPLING_DIFF_BY_ID, [block, id]);
|
|
964
|
+
if (this.has(key)) {
|
|
965
|
+
return this.get(key);
|
|
966
|
+
}
|
|
967
|
+
else {
|
|
968
|
+
const response = this.rpcClient.getSaplingDiffById(id, { block });
|
|
969
|
+
this.put(key, response);
|
|
970
|
+
return response;
|
|
971
|
+
}
|
|
1105
972
|
}
|
|
1106
973
|
/**
|
|
1107
974
|
* @param contract address of the contract we want to get the sapling diff
|
|
1108
975
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1109
|
-
*
|
|
976
|
+
* Returns the root and a diff of a state starting from an optional offset which is zero by default
|
|
1110
977
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-single-sapling-get-diff
|
|
1111
978
|
*/
|
|
1112
|
-
getSaplingDiffByContract(
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1123
|
-
});
|
|
979
|
+
async getSaplingDiffByContract(contract, { block } = defaultRPCOptions) {
|
|
980
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_SAPLING_DIFF_BY_CONTRACT, [block, contract]);
|
|
981
|
+
if (this.has(key)) {
|
|
982
|
+
return this.get(key);
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
const response = this.rpcClient.getSaplingDiffByContract(contract, { block });
|
|
986
|
+
this.put(key, response);
|
|
987
|
+
return response;
|
|
988
|
+
}
|
|
1124
989
|
}
|
|
1125
990
|
/**
|
|
1126
991
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1127
|
-
*
|
|
992
|
+
* get current and next protocol
|
|
1128
993
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-protocols
|
|
1129
994
|
*/
|
|
1130
|
-
getProtocols() {
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
}
|
|
1143
|
-
});
|
|
995
|
+
async getProtocols({ block } = defaultRPCOptions) {
|
|
996
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_PROTOCOLS, [
|
|
997
|
+
block,
|
|
998
|
+
]);
|
|
999
|
+
if (this.has(key)) {
|
|
1000
|
+
return this.get(key);
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
const response = this.rpcClient.getProtocols({ block });
|
|
1004
|
+
this.put(key, response);
|
|
1005
|
+
return response;
|
|
1006
|
+
}
|
|
1144
1007
|
}
|
|
1145
1008
|
/**
|
|
1146
|
-
* @param
|
|
1147
|
-
*
|
|
1009
|
+
* @param protocol the protocol hash to look up (default to empty string)
|
|
1010
|
+
* get current and next protocol
|
|
1148
1011
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-protocols
|
|
1149
1012
|
*/
|
|
1150
|
-
getProtocolActivations() {
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
throw new InvalidProtocolHashError(protocol, protocolValidation);
|
|
1156
|
-
}
|
|
1013
|
+
async getProtocolActivations(protocol = '') {
|
|
1014
|
+
if (protocol) {
|
|
1015
|
+
const protocolValidation = validateProtocol(protocol);
|
|
1016
|
+
if (protocolValidation !== ValidationResult.VALID) {
|
|
1017
|
+
throw new InvalidProtocolHashError(protocol, protocolValidation);
|
|
1157
1018
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
}
|
|
1019
|
+
}
|
|
1020
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_PROTOCOL_ACTIVATIONS, [protocol]);
|
|
1021
|
+
if (this.has(key)) {
|
|
1022
|
+
return this.get(key);
|
|
1023
|
+
}
|
|
1024
|
+
else {
|
|
1025
|
+
const response = this.rpcClient.getProtocolActivations(protocol);
|
|
1026
|
+
this.put(key, response);
|
|
1027
|
+
return response;
|
|
1028
|
+
}
|
|
1168
1029
|
}
|
|
1169
1030
|
/**
|
|
1170
1031
|
* @param contract address of the contract we want to retrieve storage information of
|
|
1171
1032
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1172
|
-
*
|
|
1033
|
+
* Access the used storage space of the contract
|
|
1173
1034
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1174
1035
|
*/
|
|
1175
|
-
getStorageUsedSpace(
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
}
|
|
1186
|
-
});
|
|
1036
|
+
async getStorageUsedSpace(contract, { block } = defaultRPCOptions) {
|
|
1037
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_STORAGE_USED_SPACE, [block, contract]);
|
|
1038
|
+
if (this.has(key)) {
|
|
1039
|
+
return this.get(key);
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
const response = this.rpcClient.getStorageUsedSpace(contract, { block });
|
|
1043
|
+
this.put(key, response);
|
|
1044
|
+
return response;
|
|
1045
|
+
}
|
|
1187
1046
|
}
|
|
1188
1047
|
/**
|
|
1189
1048
|
* @param contract address of the contract we want to retrieve storage information of
|
|
1190
1049
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1191
|
-
= *
|
|
1050
|
+
= * Access the paid storage space of the contract
|
|
1192
1051
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1193
1052
|
*/
|
|
1194
|
-
getStoragePaidSpace(
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1053
|
+
async getStoragePaidSpace(contract, { block } = defaultRPCOptions) {
|
|
1054
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_STORAGE_PAID_SPACE, [block, contract]);
|
|
1055
|
+
if (this.has(key)) {
|
|
1056
|
+
return this.get(key);
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
const response = this.rpcClient.getStoragePaidSpace(contract, { block });
|
|
1060
|
+
this.put(key, response);
|
|
1061
|
+
return response;
|
|
1062
|
+
}
|
|
1206
1063
|
}
|
|
1207
1064
|
/**
|
|
1208
1065
|
* @param contract implicit or originated address we want to retrieve ticket balance of
|
|
1209
1066
|
* @param ticket object to specify a ticket by ticketer, content type and content
|
|
1210
1067
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1211
|
-
*
|
|
1068
|
+
* Access the contract's balance of ticket with specified ticketer, content type, and content.
|
|
1212
1069
|
* @example ticket { ticketer: 'address', content_type: { prim: "string" }, content: { string: 'ticket1' } }
|
|
1213
1070
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1214
1071
|
*/
|
|
1215
|
-
getTicketBalance(
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
}
|
|
1226
|
-
});
|
|
1072
|
+
async getTicketBalance(contract, ticket, { block } = defaultRPCOptions) {
|
|
1073
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_TICKET_BALANCE, [block, contract], ticket);
|
|
1074
|
+
if (this.has(key)) {
|
|
1075
|
+
return this.get(key);
|
|
1076
|
+
}
|
|
1077
|
+
else {
|
|
1078
|
+
const response = this.rpcClient.getTicketBalance(contract, ticket, { block });
|
|
1079
|
+
this.put(key, response);
|
|
1080
|
+
return response;
|
|
1081
|
+
}
|
|
1227
1082
|
}
|
|
1228
1083
|
/**
|
|
1229
1084
|
* @param contract originated address we want to retrieve ticket balances of
|
|
1230
1085
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1231
|
-
*
|
|
1086
|
+
* Access the complete list of tickets owned by the given contract by scanning the contract's storage.
|
|
1232
1087
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1233
1088
|
*/
|
|
1234
|
-
getAllTicketBalances(
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
}
|
|
1245
|
-
});
|
|
1089
|
+
async getAllTicketBalances(contract, { block } = defaultRPCOptions) {
|
|
1090
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_ALL_TICKET_BALANCES, [block, contract]);
|
|
1091
|
+
if (this.has(key)) {
|
|
1092
|
+
return this.get(key);
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
const response = this.rpcClient.getAllTicketBalances(contract, { block });
|
|
1096
|
+
this.put(key, response);
|
|
1097
|
+
return response;
|
|
1098
|
+
}
|
|
1246
1099
|
}
|
|
1247
1100
|
/**
|
|
1248
|
-
*
|
|
1101
|
+
* Returns the cycle at which the launch of the Adaptive Issuance feature is set to happen. A result of null means that the feature is not yet set to launch.
|
|
1249
1102
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1250
1103
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-adaptive-issuance-launch-cycle
|
|
1251
1104
|
*/
|
|
1252
|
-
getAdaptiveIssuanceLaunchCycle() {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1105
|
+
async getAdaptiveIssuanceLaunchCycle({ block, } = defaultRPCOptions) {
|
|
1106
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_ADAPTIVE_ISSUANCE_LAUNCH_CYCLE, [block]);
|
|
1107
|
+
if (this.has(key)) {
|
|
1108
|
+
return this.get(key);
|
|
1109
|
+
}
|
|
1110
|
+
else {
|
|
1111
|
+
const response = this.rpcClient.getAdaptiveIssuanceLaunchCycle({ block });
|
|
1112
|
+
this.put(key, response);
|
|
1113
|
+
return response;
|
|
1114
|
+
}
|
|
1264
1115
|
}
|
|
1265
1116
|
/**
|
|
1266
|
-
*
|
|
1117
|
+
* List the prevalidated operations in mempool (accessibility of mempool depends on each rpc endpoint)
|
|
1267
1118
|
* @param args has 5 optional properties
|
|
1268
1119
|
* @default args { version: '2', validated: true, refused: true, outdated, true, branchRefused: true, branchDelayed: true, validationPass: undefined }
|
|
1269
1120
|
*/
|
|
1270
|
-
getPendingOperations() {
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1121
|
+
async getPendingOperations(args = {}) {
|
|
1122
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_PENDING_OPERATIONS, [args]);
|
|
1123
|
+
if (this.has(key)) {
|
|
1124
|
+
return this.get(key);
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
const response = this.rpcClient.getPendingOperations(args);
|
|
1128
|
+
this.put(key, response);
|
|
1129
|
+
return response;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Returns the current mempool fee filter configuration.
|
|
1134
|
+
* @param args optional query arguments for the mempool/filter endpoint
|
|
1135
|
+
*/
|
|
1136
|
+
async getMempoolFilter(args = {}) {
|
|
1137
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_MEMPOOL_FILTER, [
|
|
1138
|
+
args,
|
|
1139
|
+
]);
|
|
1140
|
+
if (this.has(key)) {
|
|
1141
|
+
return this.get(key);
|
|
1142
|
+
}
|
|
1143
|
+
else {
|
|
1144
|
+
const response = this.rpcClient.getMempoolFilter(args);
|
|
1145
|
+
this.put(key, response);
|
|
1146
|
+
return response;
|
|
1147
|
+
}
|
|
1282
1148
|
}
|
|
1283
1149
|
/**
|
|
1284
1150
|
* @param delegate delegate address which we want to retrieve active staking parameters
|
|
1285
1151
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1286
|
-
*
|
|
1152
|
+
* Returns the currently active staking parameters for the given delegate
|
|
1287
1153
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-active-staking-parameters
|
|
1288
1154
|
*/
|
|
1289
|
-
getActiveStakingParameters(
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
}
|
|
1301
|
-
});
|
|
1155
|
+
async getActiveStakingParameters(delegate, { block } = defaultRPCOptions) {
|
|
1156
|
+
this.validateAddress(delegate);
|
|
1157
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_ACTIVE_STAKING_PARAMETERS, [block, delegate]);
|
|
1158
|
+
if (this.has(key)) {
|
|
1159
|
+
return this.get(key);
|
|
1160
|
+
}
|
|
1161
|
+
else {
|
|
1162
|
+
const response = this.rpcClient.getActiveStakingParameters(delegate, { block });
|
|
1163
|
+
this.put(key, response);
|
|
1164
|
+
return response;
|
|
1165
|
+
}
|
|
1302
1166
|
}
|
|
1303
1167
|
/**
|
|
1304
1168
|
* @param delegate delegate address which we want to retrieve pending staking parameters
|
|
1305
1169
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1306
|
-
*
|
|
1170
|
+
* Returns the pending values for the given delegate's staking parameters
|
|
1307
1171
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-pending-staking-parameters
|
|
1308
1172
|
*/
|
|
1309
|
-
getPendingStakingParameters(
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
}
|
|
1321
|
-
});
|
|
1173
|
+
async getPendingStakingParameters(delegate, { block } = defaultRPCOptions) {
|
|
1174
|
+
this.validateAddress(delegate);
|
|
1175
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_PENDING_STAKING_PARAMETERS, [block, delegate]);
|
|
1176
|
+
if (this.has(key)) {
|
|
1177
|
+
return this.get(key);
|
|
1178
|
+
}
|
|
1179
|
+
else {
|
|
1180
|
+
const response = this.rpcClient.getPendingStakingParameters(delegate, { block });
|
|
1181
|
+
this.put(key, response);
|
|
1182
|
+
return response;
|
|
1183
|
+
}
|
|
1322
1184
|
}
|
|
1323
1185
|
/**
|
|
1324
1186
|
* @param destination address to retrieve the index for
|
|
1325
1187
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1326
|
-
*
|
|
1188
|
+
* Returns the index assigned to the address if it was indexed by the opcode INDEX_ADDRESS, otherwise returns null
|
|
1327
1189
|
* @see https://octez.tezos.com/docs/alpha/rpc.html#get-block-id-context-destination-destination-id-index
|
|
1328
1190
|
*/
|
|
1329
|
-
getDestinationIndex(
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
}
|
|
1340
|
-
});
|
|
1191
|
+
async getDestinationIndex(destination, { block } = defaultRPCOptions) {
|
|
1192
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), RPCMethodName.GET_DESTINATION_INDEX, [block, destination]);
|
|
1193
|
+
if (this.has(key)) {
|
|
1194
|
+
return this.get(key);
|
|
1195
|
+
}
|
|
1196
|
+
else {
|
|
1197
|
+
const response = this.rpcClient.getDestinationIndex(destination, { block });
|
|
1198
|
+
this.put(key, response);
|
|
1199
|
+
return response;
|
|
1200
|
+
}
|
|
1341
1201
|
}
|
|
1342
1202
|
}
|
|
1343
1203
|
|
|
@@ -1502,12 +1362,16 @@ var OpKind;
|
|
|
1502
1362
|
|
|
1503
1363
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
1504
1364
|
const VERSION = {
|
|
1505
|
-
"commitHash": "
|
|
1506
|
-
"version": "24.
|
|
1365
|
+
"commitHash": "27675679db6515e8b092195ef5c58c2c0ea5f5c8",
|
|
1366
|
+
"version": "24.3.0-beta.0"
|
|
1507
1367
|
};
|
|
1508
1368
|
|
|
1369
|
+
/**
|
|
1370
|
+
* @packageDocumentation
|
|
1371
|
+
* @module @taquito/rpc
|
|
1372
|
+
*/
|
|
1509
1373
|
/***
|
|
1510
|
-
*
|
|
1374
|
+
* RpcClient allows interaction with Tezos network through an rpc node
|
|
1511
1375
|
*/
|
|
1512
1376
|
class RpcClient {
|
|
1513
1377
|
/**
|
|
@@ -1548,743 +1412,681 @@ class RpcClient {
|
|
|
1548
1412
|
}
|
|
1549
1413
|
/**
|
|
1550
1414
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1551
|
-
*
|
|
1415
|
+
* Get the block's hash, its unique identifier.
|
|
1552
1416
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-hash
|
|
1553
1417
|
*/
|
|
1554
|
-
getBlockHash() {
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
method: 'GET',
|
|
1559
|
-
});
|
|
1560
|
-
return hash;
|
|
1418
|
+
async getBlockHash({ block } = defaultRPCOptions) {
|
|
1419
|
+
const hash = await this.httpBackend.createRequest({
|
|
1420
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/hash`),
|
|
1421
|
+
method: 'GET',
|
|
1561
1422
|
});
|
|
1423
|
+
return hash;
|
|
1562
1424
|
}
|
|
1563
1425
|
/**
|
|
1564
1426
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1565
|
-
*
|
|
1427
|
+
* List the ancestors of the given block which, if referred to as the branch in an operation header, are recent enough for that operation to be included in the current block.
|
|
1566
1428
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-live-blocks
|
|
1567
1429
|
*/
|
|
1568
|
-
getLiveBlocks() {
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
method: 'GET',
|
|
1573
|
-
});
|
|
1574
|
-
return blocks;
|
|
1430
|
+
async getLiveBlocks({ block } = defaultRPCOptions) {
|
|
1431
|
+
const blocks = await this.httpBackend.createRequest({
|
|
1432
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/live_blocks`),
|
|
1433
|
+
method: 'GET',
|
|
1575
1434
|
});
|
|
1435
|
+
return blocks;
|
|
1576
1436
|
}
|
|
1577
1437
|
/**
|
|
1578
1438
|
* @param address address from which we want to retrieve the spendable balance
|
|
1579
1439
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1580
|
-
*
|
|
1440
|
+
* The spendable balance of a contract (in mutez), also known as liquid balance. Corresponds to tez owned by the contract that are neither staked, nor in unstaked requests, nor in frozen bonds. Identical to the 'spendable' RPC.
|
|
1581
1441
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-balance
|
|
1582
1442
|
*/
|
|
1583
|
-
getBalance(
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
method: 'GET',
|
|
1589
|
-
});
|
|
1590
|
-
return new BigNumber(balance);
|
|
1443
|
+
async getBalance(address, { block } = defaultRPCOptions) {
|
|
1444
|
+
this.validateAddress(address);
|
|
1445
|
+
const balance = await this.httpBackend.createRequest({
|
|
1446
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/balance`),
|
|
1447
|
+
method: 'GET',
|
|
1591
1448
|
});
|
|
1449
|
+
return new BigNumber(balance);
|
|
1592
1450
|
}
|
|
1593
1451
|
/**
|
|
1594
1452
|
* @param address address from which we want to retrieve the spendable balance
|
|
1595
1453
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1596
|
-
*
|
|
1454
|
+
* The spendable balance of a contract (in mutez), also known as liquid balance. Corresponds to tez owned by the contract that are neither staked, nor in unstaked requests, nor in frozen bonds. Identical to the 'balance' RPC.
|
|
1597
1455
|
*/
|
|
1598
|
-
getSpendable(
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
method: 'GET',
|
|
1604
|
-
});
|
|
1605
|
-
return new BigNumber(balance);
|
|
1456
|
+
async getSpendable(address, { block } = defaultRPCOptions) {
|
|
1457
|
+
this.validateAddress(address);
|
|
1458
|
+
const balance = await this.httpBackend.createRequest({
|
|
1459
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/spendable`),
|
|
1460
|
+
method: 'GET',
|
|
1606
1461
|
});
|
|
1462
|
+
return new BigNumber(balance);
|
|
1607
1463
|
}
|
|
1608
1464
|
/**
|
|
1609
1465
|
* @param address address from which we want to retrieve balance and frozen bonds
|
|
1610
1466
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1611
|
-
*
|
|
1467
|
+
* The sum (in mutez) of the spendable balance and frozen bonds of a contract. Corresponds to the contract's full balance from which staked funds and unstake requests have been excluded. Identical to the 'spendable_and_frozen_bonds' RPC.
|
|
1612
1468
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-full-balance
|
|
1613
1469
|
*/
|
|
1614
|
-
getBalanceAndFrozenBonds(
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
method: 'GET',
|
|
1620
|
-
});
|
|
1621
|
-
return new BigNumber(balance);
|
|
1470
|
+
async getBalanceAndFrozenBonds(address, { block } = defaultRPCOptions) {
|
|
1471
|
+
this.validateAddress(address);
|
|
1472
|
+
const balance = await this.httpBackend.createRequest({
|
|
1473
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/balance_and_frozen_bonds`),
|
|
1474
|
+
method: 'GET',
|
|
1622
1475
|
});
|
|
1476
|
+
return new BigNumber(balance);
|
|
1623
1477
|
}
|
|
1624
1478
|
/**
|
|
1625
1479
|
* @param address address from which we want to retrieve spendable and frozen bonds
|
|
1626
1480
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1627
|
-
*
|
|
1481
|
+
* The sum (in mutez) of the spendable balance and frozen bonds of a contract. Corresponds to the contract's full balance from which staked funds and unstake requests have been excluded. Identical to the 'balance_and_frozen_bonds' RPC.
|
|
1628
1482
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-full-balance
|
|
1629
1483
|
*/
|
|
1630
|
-
getSpendableAndFrozenBonds(
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
method: 'GET',
|
|
1636
|
-
});
|
|
1637
|
-
return new BigNumber(balance);
|
|
1484
|
+
async getSpendableAndFrozenBonds(address, { block } = defaultRPCOptions) {
|
|
1485
|
+
this.validateAddress(address);
|
|
1486
|
+
const balance = await this.httpBackend.createRequest({
|
|
1487
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/spendable_and_frozen_bonds`),
|
|
1488
|
+
method: 'GET',
|
|
1638
1489
|
});
|
|
1490
|
+
return new BigNumber(balance);
|
|
1639
1491
|
}
|
|
1640
1492
|
/**
|
|
1641
1493
|
* @param address address from which we want to retrieve the full balance
|
|
1642
1494
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1643
|
-
*
|
|
1495
|
+
* Access the full balance of a contract, including frozen bonds and stake.
|
|
1644
1496
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-full-balance
|
|
1645
1497
|
*/
|
|
1646
|
-
getFullBalance(
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
method: 'GET',
|
|
1652
|
-
});
|
|
1653
|
-
return new BigNumber(balance);
|
|
1498
|
+
async getFullBalance(address, { block } = defaultRPCOptions) {
|
|
1499
|
+
this.validateAddress(address);
|
|
1500
|
+
const balance = await this.httpBackend.createRequest({
|
|
1501
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/full_balance`),
|
|
1502
|
+
method: 'GET',
|
|
1654
1503
|
});
|
|
1504
|
+
return new BigNumber(balance);
|
|
1655
1505
|
}
|
|
1656
1506
|
/**
|
|
1657
1507
|
* @param address address from which we want to retrieve the staked balance
|
|
1658
1508
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1659
|
-
*
|
|
1509
|
+
* Access the staked balance of a contract. Returns None if the contract is originated, or neither delegated nor a delegate.
|
|
1660
1510
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-staked-balance
|
|
1661
1511
|
*/
|
|
1662
|
-
getStakedBalance(
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
method: 'GET',
|
|
1668
|
-
});
|
|
1669
|
-
return new BigNumber(balance);
|
|
1512
|
+
async getStakedBalance(address, { block } = defaultRPCOptions) {
|
|
1513
|
+
this.validateAddress(address);
|
|
1514
|
+
const balance = await this.httpBackend.createRequest({
|
|
1515
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/staked_balance`),
|
|
1516
|
+
method: 'GET',
|
|
1670
1517
|
});
|
|
1518
|
+
return new BigNumber(balance);
|
|
1671
1519
|
}
|
|
1672
1520
|
/**
|
|
1673
1521
|
* @param address address from which we want to retrieve the unstaked finalizable balance
|
|
1674
1522
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1675
|
-
*
|
|
1523
|
+
* Access the balance of a contract that was requested for an unstake operation, and is no longer frozen, which means it will appear in the spendable balance of the contract after any stake/unstake/finalize_unstake operation. Returns None if the contract is originated.
|
|
1676
1524
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstaked-finalizable-balance
|
|
1677
1525
|
*/
|
|
1678
|
-
getUnstakedFinalizableBalance(
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
method: 'GET',
|
|
1684
|
-
});
|
|
1685
|
-
return new BigNumber(balance);
|
|
1526
|
+
async getUnstakedFinalizableBalance(address, { block } = defaultRPCOptions) {
|
|
1527
|
+
this.validateAddress(address);
|
|
1528
|
+
const balance = await this.httpBackend.createRequest({
|
|
1529
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/unstaked_finalizable_balance`),
|
|
1530
|
+
method: 'GET',
|
|
1686
1531
|
});
|
|
1532
|
+
return new BigNumber(balance);
|
|
1687
1533
|
}
|
|
1688
1534
|
/**
|
|
1689
1535
|
* @param address address from which we want to retrieve the unstaked frozen balance
|
|
1690
1536
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1691
|
-
*
|
|
1537
|
+
* Access the balance of a contract that was requested for an unstake operation, but is still frozen for the duration of the slashing period. Returns None if the contract is originated.
|
|
1692
1538
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstaked-frozen-balance
|
|
1693
1539
|
*/
|
|
1694
|
-
getUnstakedFrozenBalance(
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
method: 'GET',
|
|
1700
|
-
});
|
|
1701
|
-
return new BigNumber(balance);
|
|
1540
|
+
async getUnstakedFrozenBalance(address, { block } = defaultRPCOptions) {
|
|
1541
|
+
this.validateAddress(address);
|
|
1542
|
+
const balance = await this.httpBackend.createRequest({
|
|
1543
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/unstaked_frozen_balance`),
|
|
1544
|
+
method: 'GET',
|
|
1702
1545
|
});
|
|
1546
|
+
return new BigNumber(balance);
|
|
1703
1547
|
}
|
|
1704
1548
|
/**
|
|
1705
1549
|
* @param address address from which we want to retrieve the unstaked requests
|
|
1706
1550
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1707
|
-
*
|
|
1551
|
+
* Access the unstake requests of the contract. The requests that appear in the finalizable field can be finalized, which means that the contract can transfer these (no longer frozen) funds to their spendable balance with a [finalize_unstake] operation call. Returns null if there is no unstake request pending.
|
|
1708
1552
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstake-requests
|
|
1709
1553
|
*/
|
|
1710
|
-
getUnstakeRequests(
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
: {
|
|
1720
|
-
|
|
1721
|
-
|
|
1554
|
+
async getUnstakeRequests(address, { block } = defaultRPCOptions) {
|
|
1555
|
+
this.validateAddress(address);
|
|
1556
|
+
const response = await this.httpBackend.createRequest({
|
|
1557
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/unstake_requests`),
|
|
1558
|
+
method: 'GET',
|
|
1559
|
+
});
|
|
1560
|
+
return response === null
|
|
1561
|
+
? null
|
|
1562
|
+
: {
|
|
1563
|
+
finalizable: response.finalizable.map(({ amount, ...rest }) => {
|
|
1564
|
+
const castedToBigNumber = castToBigNumber({ amount }, ['amount']);
|
|
1565
|
+
return {
|
|
1566
|
+
...rest,
|
|
1567
|
+
amount: castedToBigNumber.amount,
|
|
1568
|
+
};
|
|
1569
|
+
}),
|
|
1570
|
+
unfinalizable: {
|
|
1571
|
+
delegate: response.unfinalizable.delegate,
|
|
1572
|
+
requests: response.unfinalizable.requests.map(({ amount, cycle }) => {
|
|
1722
1573
|
const castedToBigNumber = castToBigNumber({ amount }, ['amount']);
|
|
1723
|
-
return
|
|
1574
|
+
return {
|
|
1575
|
+
cycle,
|
|
1576
|
+
amount: castedToBigNumber.amount,
|
|
1577
|
+
};
|
|
1724
1578
|
}),
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
requests: response.unfinalizable.requests.map(({ amount, cycle }) => {
|
|
1728
|
-
const castedToBigNumber = castToBigNumber({ amount }, ['amount']);
|
|
1729
|
-
return {
|
|
1730
|
-
cycle,
|
|
1731
|
-
amount: castedToBigNumber.amount,
|
|
1732
|
-
};
|
|
1733
|
-
}),
|
|
1734
|
-
},
|
|
1735
|
-
};
|
|
1736
|
-
});
|
|
1579
|
+
},
|
|
1580
|
+
};
|
|
1737
1581
|
}
|
|
1738
1582
|
/**
|
|
1739
1583
|
* @param address contract address from which we want to retrieve the storage
|
|
1740
1584
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1741
|
-
*
|
|
1585
|
+
* Access the data of the contract.
|
|
1742
1586
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-storage
|
|
1743
1587
|
*/
|
|
1744
|
-
getStorage(
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
method: 'GET',
|
|
1750
|
-
});
|
|
1588
|
+
async getStorage(address, { block } = defaultRPCOptions) {
|
|
1589
|
+
this.validateContract(address);
|
|
1590
|
+
return this.httpBackend.createRequest({
|
|
1591
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/storage`),
|
|
1592
|
+
method: 'GET',
|
|
1751
1593
|
});
|
|
1752
1594
|
}
|
|
1753
1595
|
/**
|
|
1754
1596
|
* @param address contract address from which we want to retrieve the script
|
|
1755
1597
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1756
|
-
*
|
|
1598
|
+
* Access the code and data of the contract.
|
|
1757
1599
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-script
|
|
1758
1600
|
*/
|
|
1759
|
-
getScript(
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
method: 'GET',
|
|
1765
|
-
});
|
|
1601
|
+
async getScript(address, { block } = defaultRPCOptions) {
|
|
1602
|
+
this.validateContract(address);
|
|
1603
|
+
return this.httpBackend.createRequest({
|
|
1604
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/script`),
|
|
1605
|
+
method: 'GET',
|
|
1766
1606
|
});
|
|
1767
1607
|
}
|
|
1768
1608
|
/**
|
|
1769
1609
|
* @param address contract address from which we want to retrieve the script
|
|
1770
1610
|
* @param unparsingMode default is { unparsing_mode: "Readable" }
|
|
1771
1611
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1772
|
-
*
|
|
1612
|
+
* Access the script of the contract and normalize it using the requested unparsing mode.
|
|
1773
1613
|
*/
|
|
1774
|
-
getNormalizedScript(
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
}, unparsingMode);
|
|
1781
|
-
});
|
|
1614
|
+
async getNormalizedScript(address, unparsingMode = { unparsing_mode: 'Readable' }, { block } = defaultRPCOptions) {
|
|
1615
|
+
this.validateContract(address);
|
|
1616
|
+
return this.httpBackend.createRequest({
|
|
1617
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/script/normalized`),
|
|
1618
|
+
method: 'POST',
|
|
1619
|
+
}, unparsingMode);
|
|
1782
1620
|
}
|
|
1783
1621
|
/**
|
|
1784
1622
|
* @param address contract address from which we want to retrieve
|
|
1785
1623
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1786
|
-
*
|
|
1624
|
+
* Access the complete status of a contract.
|
|
1787
1625
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id
|
|
1788
1626
|
*/
|
|
1789
|
-
getContract(
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
method: 'GET',
|
|
1795
|
-
});
|
|
1796
|
-
return Object.assign(Object.assign({}, contractResponse), { balance: new BigNumber(contractResponse.balance) });
|
|
1627
|
+
async getContract(address, { block } = defaultRPCOptions) {
|
|
1628
|
+
this.validateAddress(address);
|
|
1629
|
+
const contractResponse = await this.httpBackend.createRequest({
|
|
1630
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}`),
|
|
1631
|
+
method: 'GET',
|
|
1797
1632
|
});
|
|
1633
|
+
return {
|
|
1634
|
+
...contractResponse,
|
|
1635
|
+
balance: new BigNumber(contractResponse.balance),
|
|
1636
|
+
};
|
|
1798
1637
|
}
|
|
1799
1638
|
/**
|
|
1800
1639
|
* @param address contract address from which we want to retrieve the manager
|
|
1801
1640
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1802
|
-
*
|
|
1641
|
+
* Access the manager of an implicit contract
|
|
1803
1642
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-manager-key
|
|
1804
1643
|
*/
|
|
1805
|
-
getManagerKey(
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
method: 'GET',
|
|
1811
|
-
});
|
|
1644
|
+
async getManagerKey(address, { block } = defaultRPCOptions) {
|
|
1645
|
+
this.validateAddress(address);
|
|
1646
|
+
return this.httpBackend.createRequest({
|
|
1647
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/manager_key`),
|
|
1648
|
+
method: 'GET',
|
|
1812
1649
|
});
|
|
1813
1650
|
}
|
|
1814
1651
|
/**
|
|
1815
1652
|
* @param address contract address from which we want to retrieve the delegate (baker)
|
|
1816
1653
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1817
|
-
*
|
|
1654
|
+
* Access the delegate of a contract, if any
|
|
1818
1655
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-delegate
|
|
1819
1656
|
*/
|
|
1820
|
-
getDelegate(
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1657
|
+
async getDelegate(address, { block } = defaultRPCOptions) {
|
|
1658
|
+
this.validateAddress(address);
|
|
1659
|
+
let delegate;
|
|
1660
|
+
try {
|
|
1661
|
+
delegate = await this.httpBackend.createRequest({
|
|
1662
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/delegate`),
|
|
1663
|
+
method: 'GET',
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
catch (ex) {
|
|
1667
|
+
if (ex instanceof HttpResponseError && ex.status === STATUS_CODE.NOT_FOUND) {
|
|
1668
|
+
delegate = null;
|
|
1829
1669
|
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
delegate = null;
|
|
1833
|
-
}
|
|
1834
|
-
else {
|
|
1835
|
-
throw ex;
|
|
1836
|
-
}
|
|
1670
|
+
else {
|
|
1671
|
+
throw ex;
|
|
1837
1672
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1673
|
+
}
|
|
1674
|
+
return delegate;
|
|
1840
1675
|
}
|
|
1841
1676
|
/**
|
|
1842
1677
|
* @param id Big Map ID
|
|
1843
1678
|
* @param expr Expression hash to query (A b58check encoded Blake2b hash of the expression (The expression can be packed using the pack_data method))
|
|
1844
1679
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1845
|
-
*
|
|
1680
|
+
* Access the value associated with a key in a big map.
|
|
1846
1681
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-big-maps-big-map-id-script-expr
|
|
1847
1682
|
*/
|
|
1848
|
-
getBigMapExpr(
|
|
1849
|
-
return
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
method: 'GET',
|
|
1853
|
-
});
|
|
1683
|
+
async getBigMapExpr(id, expr, { block } = defaultRPCOptions) {
|
|
1684
|
+
return this.httpBackend.createRequest({
|
|
1685
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/big_maps/${id}/${expr}`),
|
|
1686
|
+
method: 'GET',
|
|
1854
1687
|
});
|
|
1855
1688
|
}
|
|
1856
1689
|
/**
|
|
1857
1690
|
* @param args contains optional query arguments (active, inactive, with_minimal_stake, without_minimal_stake)
|
|
1858
1691
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1859
|
-
*
|
|
1692
|
+
* Lists all registered delegates by default with query arguments to filter unneeded values.
|
|
1860
1693
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh
|
|
1861
1694
|
*/
|
|
1862
|
-
getAllDelegates() {
|
|
1863
|
-
return
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
query: args,
|
|
1868
|
-
});
|
|
1695
|
+
async getAllDelegates(args = {}, { block } = defaultRPCOptions) {
|
|
1696
|
+
return await this.httpBackend.createRequest({
|
|
1697
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates`),
|
|
1698
|
+
method: 'GET',
|
|
1699
|
+
query: args,
|
|
1869
1700
|
});
|
|
1870
1701
|
}
|
|
1871
1702
|
/**
|
|
1872
1703
|
* @param address delegate address which we want to retrieve
|
|
1873
1704
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1874
|
-
*
|
|
1705
|
+
* Everything about a delegate
|
|
1875
1706
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh
|
|
1876
1707
|
*/
|
|
1877
|
-
getDelegates(
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1708
|
+
async getDelegates(address, { block } = defaultRPCOptions) {
|
|
1709
|
+
this.validateAddress(address);
|
|
1710
|
+
const response = await this.httpBackend.createRequest({
|
|
1711
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates/${address}`),
|
|
1712
|
+
method: 'GET',
|
|
1713
|
+
});
|
|
1714
|
+
const castedResponse = castToBigNumber(response, [
|
|
1715
|
+
'balance',
|
|
1716
|
+
'full_balance',
|
|
1717
|
+
'current_frozen_deposits',
|
|
1718
|
+
'frozen_deposits',
|
|
1719
|
+
'frozen_balance',
|
|
1720
|
+
'frozen_deposits_limit',
|
|
1721
|
+
'staking_balance',
|
|
1722
|
+
'delegated_balance',
|
|
1723
|
+
'voting_power',
|
|
1724
|
+
'total_delegated_stake',
|
|
1725
|
+
'staking_denominator',
|
|
1726
|
+
]);
|
|
1727
|
+
if (response.frozen_balance_by_cycle) {
|
|
1728
|
+
return {
|
|
1729
|
+
...response,
|
|
1730
|
+
...castedResponse,
|
|
1731
|
+
frozen_balance_by_cycle: response.frozen_balance_by_cycle.map(({ deposit, deposits, fees, rewards, ...rest }) => {
|
|
1732
|
+
const castedToBigNumber = castToBigNumber({ deposit, deposits, fees, rewards }, [
|
|
1733
|
+
'deposit',
|
|
1734
|
+
'deposits',
|
|
1735
|
+
'fees',
|
|
1736
|
+
'rewards',
|
|
1737
|
+
]);
|
|
1738
|
+
return {
|
|
1739
|
+
...rest,
|
|
1740
|
+
deposit: castedToBigNumber.deposit,
|
|
1741
|
+
deposits: castedToBigNumber.deposits,
|
|
1742
|
+
fees: castedToBigNumber.fees,
|
|
1743
|
+
rewards: castedToBigNumber.rewards,
|
|
1744
|
+
};
|
|
1745
|
+
}),
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
else {
|
|
1749
|
+
return {
|
|
1750
|
+
...response,
|
|
1751
|
+
...castedResponse,
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1913
1754
|
}
|
|
1914
1755
|
/**
|
|
1915
1756
|
* @param address delegate address which we want to retrieve
|
|
1916
1757
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1917
|
-
*
|
|
1758
|
+
* Returns the delegate info (e.g. voting power) found in the listings of the current voting period
|
|
1918
1759
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-voting-info
|
|
1919
1760
|
*/
|
|
1920
|
-
getVotingInfo(
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
method: 'GET',
|
|
1926
|
-
});
|
|
1761
|
+
async getVotingInfo(address, { block } = defaultRPCOptions) {
|
|
1762
|
+
this.validateAddress(address);
|
|
1763
|
+
return await this.httpBackend.createRequest({
|
|
1764
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates/${address}/voting_info`),
|
|
1765
|
+
method: 'GET',
|
|
1927
1766
|
});
|
|
1928
1767
|
}
|
|
1929
1768
|
/**
|
|
1930
1769
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1931
|
-
*
|
|
1770
|
+
* All constants
|
|
1932
1771
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-constants
|
|
1933
1772
|
*/
|
|
1934
|
-
getConstants() {
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1773
|
+
async getConstants({ block } = defaultRPCOptions) {
|
|
1774
|
+
const response = await this.httpBackend.createRequest({
|
|
1775
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/constants`),
|
|
1776
|
+
method: 'GET',
|
|
1777
|
+
});
|
|
1778
|
+
const castedResponse = castToBigNumber(response, [
|
|
1779
|
+
'time_between_blocks',
|
|
1780
|
+
'hard_gas_limit_per_operation',
|
|
1781
|
+
'hard_gas_limit_per_block',
|
|
1782
|
+
'proof_of_work_threshold',
|
|
1783
|
+
'tokens_per_roll',
|
|
1784
|
+
'seed_nonce_revelation_tip',
|
|
1785
|
+
'block_security_deposit',
|
|
1786
|
+
'endorsement_security_deposit',
|
|
1787
|
+
'block_reward',
|
|
1788
|
+
'endorsement_reward',
|
|
1789
|
+
'cost_per_byte',
|
|
1790
|
+
'hard_storage_limit_per_operation',
|
|
1791
|
+
'test_chain_duration',
|
|
1792
|
+
'baking_reward_per_endorsement',
|
|
1793
|
+
'delay_per_missing_endorsement',
|
|
1794
|
+
'minimal_block_delay',
|
|
1795
|
+
'liquidity_baking_subsidy',
|
|
1796
|
+
'cache_layout',
|
|
1797
|
+
'baking_reward_fixed_portion',
|
|
1798
|
+
'baking_reward_bonus_per_slot',
|
|
1799
|
+
'endorsing_reward_per_slot',
|
|
1800
|
+
'double_baking_punishment',
|
|
1801
|
+
'delay_increment_per_round',
|
|
1802
|
+
'tx_rollup_commitment_bond',
|
|
1803
|
+
'vdf_difficulty',
|
|
1804
|
+
'sc_rollup_stake_amount',
|
|
1805
|
+
'minimal_stake',
|
|
1806
|
+
]);
|
|
1807
|
+
return {
|
|
1808
|
+
...response,
|
|
1809
|
+
...castedResponse,
|
|
1810
|
+
};
|
|
1971
1811
|
}
|
|
1972
1812
|
/**
|
|
1973
1813
|
* @param options contains generic configuration for rpc calls to specified block (default to head) and version.
|
|
1974
|
-
*
|
|
1814
|
+
* All the information about a block
|
|
1975
1815
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id
|
|
1976
1816
|
* @example getBlock() will default to `/main/chains/block/head?version=1`
|
|
1977
1817
|
* @example getBlock({ block: 'head~2' }) will return an offset of 2 from head blocks
|
|
1978
1818
|
* @example getBlock({ block: 'BL8fTiWcSxWCjiMVnDkbh6EuhqVPZzgWheJ2dqwrxYRm9AephXh~2' }) will return an offset of 2 blocks from given block hash..
|
|
1979
1819
|
*/
|
|
1980
|
-
getBlock() {
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
return yield this.httpBackend.createRequest(requestOptions);
|
|
1990
|
-
});
|
|
1820
|
+
async getBlock({ block, version } = defaultRPCOptions) {
|
|
1821
|
+
const requestOptions = {
|
|
1822
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}`),
|
|
1823
|
+
method: 'GET',
|
|
1824
|
+
};
|
|
1825
|
+
if (version !== undefined) {
|
|
1826
|
+
requestOptions.query = { version };
|
|
1827
|
+
}
|
|
1828
|
+
return await this.httpBackend.createRequest(requestOptions);
|
|
1991
1829
|
}
|
|
1992
1830
|
/**
|
|
1993
1831
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1994
|
-
*
|
|
1832
|
+
* The whole block header
|
|
1995
1833
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-header
|
|
1996
1834
|
*/
|
|
1997
|
-
getBlockHeader() {
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
method: 'GET',
|
|
2002
|
-
});
|
|
2003
|
-
return response;
|
|
1835
|
+
async getBlockHeader({ block } = defaultRPCOptions) {
|
|
1836
|
+
const response = await this.httpBackend.createRequest({
|
|
1837
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/header`),
|
|
1838
|
+
method: 'GET',
|
|
2004
1839
|
});
|
|
1840
|
+
return response;
|
|
2005
1841
|
}
|
|
2006
1842
|
/**
|
|
2007
1843
|
* @param options contains generic configuration for rpc calls to specified block (default to head) and version
|
|
2008
|
-
*
|
|
1844
|
+
* All the metadata associated to the block
|
|
2009
1845
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-metadata
|
|
2010
1846
|
*/
|
|
2011
|
-
getBlockMetadata() {
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
return yield this.httpBackend.createRequest(requestOptions);
|
|
2021
|
-
});
|
|
1847
|
+
async getBlockMetadata({ block, version, } = defaultRPCOptions) {
|
|
1848
|
+
const requestOptions = {
|
|
1849
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/metadata`),
|
|
1850
|
+
method: 'GET',
|
|
1851
|
+
};
|
|
1852
|
+
if (version !== undefined) {
|
|
1853
|
+
requestOptions.query = { version };
|
|
1854
|
+
}
|
|
1855
|
+
return await this.httpBackend.createRequest(requestOptions);
|
|
2022
1856
|
}
|
|
2023
1857
|
/**
|
|
2024
1858
|
* @param args contains optional query arguments (level, cycle, delegate, consensus_key, and max_round)
|
|
2025
1859
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2026
|
-
*
|
|
1860
|
+
* Retrieves the list of delegates allowed to bake a block.
|
|
2027
1861
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2028
1862
|
*/
|
|
2029
|
-
getBakingRights() {
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
query: args,
|
|
2035
|
-
});
|
|
2036
|
-
return response;
|
|
1863
|
+
async getBakingRights(args = {}, { block } = defaultRPCOptions) {
|
|
1864
|
+
const response = await this.httpBackend.createRequest({
|
|
1865
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/baking_rights`),
|
|
1866
|
+
method: 'GET',
|
|
1867
|
+
query: args,
|
|
2037
1868
|
});
|
|
1869
|
+
return response;
|
|
2038
1870
|
}
|
|
2039
1871
|
/**
|
|
2040
1872
|
* @param args contains optional query arguments (level, cycle, delegate, and consensus_key)
|
|
2041
1873
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2042
|
-
*
|
|
1874
|
+
* Retrieves the delegates allowed to attest a block
|
|
2043
1875
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2044
1876
|
*/
|
|
2045
|
-
getAttestationRights() {
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
query: args,
|
|
2051
|
-
});
|
|
2052
|
-
return response;
|
|
1877
|
+
async getAttestationRights(args = {}, { block } = defaultRPCOptions) {
|
|
1878
|
+
const response = await this.httpBackend.createRequest({
|
|
1879
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/attestation_rights`),
|
|
1880
|
+
method: 'GET',
|
|
1881
|
+
query: args,
|
|
2053
1882
|
});
|
|
1883
|
+
return response;
|
|
2054
1884
|
}
|
|
2055
1885
|
/**
|
|
2056
1886
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2057
|
-
*
|
|
1887
|
+
* Ballots casted so far during a voting period
|
|
2058
1888
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-ballot-list
|
|
2059
1889
|
*/
|
|
2060
|
-
getBallotList() {
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
method: 'GET',
|
|
2065
|
-
});
|
|
2066
|
-
return response;
|
|
1890
|
+
async getBallotList({ block } = defaultRPCOptions) {
|
|
1891
|
+
const response = await this.httpBackend.createRequest({
|
|
1892
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/ballot_list`),
|
|
1893
|
+
method: 'GET',
|
|
2067
1894
|
});
|
|
1895
|
+
return response;
|
|
2068
1896
|
}
|
|
2069
1897
|
/**
|
|
2070
1898
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2071
|
-
*
|
|
1899
|
+
* Sum of ballots casted so far during a voting period
|
|
2072
1900
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-ballots
|
|
2073
1901
|
*/
|
|
2074
|
-
getBallots() {
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
method: 'GET',
|
|
2079
|
-
});
|
|
2080
|
-
const casted = castToBigNumber(response, ['yay', 'nay', 'pass']);
|
|
2081
|
-
return casted;
|
|
1902
|
+
async getBallots({ block } = defaultRPCOptions) {
|
|
1903
|
+
const response = await this.httpBackend.createRequest({
|
|
1904
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/ballots`),
|
|
1905
|
+
method: 'GET',
|
|
2082
1906
|
});
|
|
1907
|
+
const casted = castToBigNumber(response, ['yay', 'nay', 'pass']);
|
|
1908
|
+
return casted;
|
|
2083
1909
|
}
|
|
2084
1910
|
/**
|
|
2085
1911
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2086
|
-
*
|
|
1912
|
+
* Current proposal under evaluation.
|
|
2087
1913
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-proposal
|
|
2088
1914
|
*/
|
|
2089
|
-
getCurrentProposal() {
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
method: 'GET',
|
|
2094
|
-
});
|
|
2095
|
-
return response;
|
|
1915
|
+
async getCurrentProposal({ block, } = defaultRPCOptions) {
|
|
1916
|
+
const response = await this.httpBackend.createRequest({
|
|
1917
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/current_proposal`),
|
|
1918
|
+
method: 'GET',
|
|
2096
1919
|
});
|
|
1920
|
+
return response;
|
|
2097
1921
|
}
|
|
2098
1922
|
/**
|
|
2099
1923
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2100
|
-
*
|
|
1924
|
+
* Current expected quorum.
|
|
2101
1925
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-quorum
|
|
2102
1926
|
*/
|
|
2103
|
-
getCurrentQuorum() {
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
method: 'GET',
|
|
2108
|
-
});
|
|
2109
|
-
return response;
|
|
1927
|
+
async getCurrentQuorum({ block, } = defaultRPCOptions) {
|
|
1928
|
+
const response = await this.httpBackend.createRequest({
|
|
1929
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/current_quorum`),
|
|
1930
|
+
method: 'GET',
|
|
2110
1931
|
});
|
|
1932
|
+
return response;
|
|
2111
1933
|
}
|
|
2112
1934
|
/**
|
|
2113
1935
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2114
|
-
*
|
|
1936
|
+
* List of delegates with their voting power
|
|
2115
1937
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-listings
|
|
2116
1938
|
*/
|
|
2117
|
-
getVotesListings() {
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
return item;
|
|
2128
|
-
});
|
|
2129
|
-
return response;
|
|
1939
|
+
async getVotesListings({ block, } = defaultRPCOptions) {
|
|
1940
|
+
const response = await this.httpBackend.createRequest({
|
|
1941
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/listings`),
|
|
1942
|
+
method: 'GET',
|
|
1943
|
+
});
|
|
1944
|
+
response.map((item) => {
|
|
1945
|
+
if (item.voting_power) {
|
|
1946
|
+
item.voting_power = new BigNumber(item.voting_power);
|
|
1947
|
+
}
|
|
1948
|
+
return item;
|
|
2130
1949
|
});
|
|
1950
|
+
return response;
|
|
2131
1951
|
}
|
|
2132
1952
|
/**
|
|
2133
1953
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2134
|
-
*
|
|
1954
|
+
* List of proposals with number of supporters
|
|
2135
1955
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-proposals
|
|
2136
1956
|
*/
|
|
2137
|
-
getProposals() {
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
return (item[1] = new BigNumber(item[1]));
|
|
2145
|
-
});
|
|
2146
|
-
return response;
|
|
1957
|
+
async getProposals({ block } = defaultRPCOptions) {
|
|
1958
|
+
const response = await this.httpBackend.createRequest({
|
|
1959
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/proposals`),
|
|
1960
|
+
method: 'GET',
|
|
1961
|
+
});
|
|
1962
|
+
response.map((item) => {
|
|
1963
|
+
return (item[1] = new BigNumber(item[1]));
|
|
2147
1964
|
});
|
|
1965
|
+
return response;
|
|
2148
1966
|
}
|
|
2149
1967
|
/**
|
|
2150
1968
|
* @param data operation contents to forge
|
|
2151
1969
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2152
|
-
*
|
|
1970
|
+
* Forge an operation returning the unsigned bytes
|
|
2153
1971
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2154
1972
|
*/
|
|
2155
|
-
forgeOperations(
|
|
2156
|
-
return
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
}, data);
|
|
2161
|
-
});
|
|
1973
|
+
async forgeOperations(data, { block } = defaultRPCOptions) {
|
|
1974
|
+
return this.httpBackend.createRequest({
|
|
1975
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/forge/operations`),
|
|
1976
|
+
method: 'POST',
|
|
1977
|
+
}, data);
|
|
2162
1978
|
}
|
|
2163
1979
|
/**
|
|
2164
1980
|
* @param signedOpBytes signed bytes to inject
|
|
2165
|
-
*
|
|
1981
|
+
* Inject an operation in node and broadcast it and return the ID of the operation
|
|
2166
1982
|
* @see https://tezos.gitlab.io/shell/rpc.html#post-injection-operation
|
|
2167
1983
|
*/
|
|
2168
|
-
injectOperation(signedOpBytes) {
|
|
2169
|
-
return
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
}, signedOpBytes);
|
|
2174
|
-
});
|
|
1984
|
+
async injectOperation(signedOpBytes) {
|
|
1985
|
+
return this.httpBackend.createRequest({
|
|
1986
|
+
url: this.createURL(`/injection/operation`),
|
|
1987
|
+
method: 'POST',
|
|
1988
|
+
}, signedOpBytes);
|
|
2175
1989
|
}
|
|
2176
1990
|
/**
|
|
2177
1991
|
* @param ops Operations to apply
|
|
2178
1992
|
* @param options contains generic configuration for rpc calls to specified block and version
|
|
2179
|
-
*
|
|
1993
|
+
* Simulate the application of the operations with the context of the given block and return the result of each operation application
|
|
2180
1994
|
* @see https://tezos.gitlab.io/active/rpc.html#post-block-id-helpers-preapply-operations
|
|
2181
1995
|
*/
|
|
2182
|
-
preapplyOperations(
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
return yield this.httpBackend.createRequest(requestOptions, ops);
|
|
2192
|
-
});
|
|
1996
|
+
async preapplyOperations(ops, { block, version } = defaultRPCOptions) {
|
|
1997
|
+
const requestOptions = {
|
|
1998
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/preapply/operations`),
|
|
1999
|
+
method: 'POST',
|
|
2000
|
+
};
|
|
2001
|
+
if (version !== undefined) {
|
|
2002
|
+
requestOptions.query = { version };
|
|
2003
|
+
}
|
|
2004
|
+
return await this.httpBackend.createRequest(requestOptions, ops);
|
|
2193
2005
|
}
|
|
2194
2006
|
/**
|
|
2195
2007
|
* @param contract address of the contract we want to get the entrypoints of
|
|
2196
2008
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2197
|
-
*
|
|
2009
|
+
* Return the list of entrypoints of the contract
|
|
2198
2010
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-entrypoints
|
|
2199
|
-
* @version 005_PsBABY5H
|
|
2011
|
+
* @remarks version 005_PsBABY5H
|
|
2200
2012
|
*/
|
|
2201
|
-
getEntrypoints(
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
method: 'GET',
|
|
2207
|
-
});
|
|
2208
|
-
return contractResponse;
|
|
2013
|
+
async getEntrypoints(contract, { block } = defaultRPCOptions) {
|
|
2014
|
+
this.validateContract(contract);
|
|
2015
|
+
const contractResponse = await this.httpBackend.createRequest({
|
|
2016
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/entrypoints`),
|
|
2017
|
+
method: 'GET',
|
|
2209
2018
|
});
|
|
2019
|
+
return contractResponse;
|
|
2210
2020
|
}
|
|
2211
2021
|
/**
|
|
2212
2022
|
* @param op Operation to simulate
|
|
2213
2023
|
* @param options contains generic configuration for rpc calls to specified block and version
|
|
2214
|
-
*
|
|
2024
|
+
* Simulate running an operation at some future moment (based on the number of blocks given in the `latency` argument), and return the operation application result.
|
|
2215
2025
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2216
2026
|
*/
|
|
2217
|
-
simulateOperation(
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
return yield this.httpBackend.createRequest(requestOptions, op);
|
|
2227
|
-
});
|
|
2027
|
+
async simulateOperation(op, { block, version } = defaultRPCOptions) {
|
|
2028
|
+
const requestOptions = {
|
|
2029
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/simulate_operation`),
|
|
2030
|
+
method: 'POST',
|
|
2031
|
+
};
|
|
2032
|
+
if (version !== undefined) {
|
|
2033
|
+
requestOptions.query = { version };
|
|
2034
|
+
}
|
|
2035
|
+
return await this.httpBackend.createRequest(requestOptions, op);
|
|
2228
2036
|
}
|
|
2229
2037
|
/**
|
|
2230
2038
|
* @param code Code to run
|
|
2231
2039
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2232
|
-
*
|
|
2040
|
+
* Run a Michelson script in the current context
|
|
2233
2041
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2234
2042
|
*/
|
|
2235
|
-
runCode(
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
return response;
|
|
2242
|
-
});
|
|
2043
|
+
async runCode(code, { block } = defaultRPCOptions) {
|
|
2044
|
+
const response = await this.httpBackend.createRequest({
|
|
2045
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/run_code`),
|
|
2046
|
+
method: 'POST',
|
|
2047
|
+
}, code);
|
|
2048
|
+
return response;
|
|
2243
2049
|
}
|
|
2244
2050
|
/**
|
|
2245
2051
|
* @param viewScriptParams Parameters of the script view to run
|
|
2246
2052
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2247
|
-
*
|
|
2053
|
+
* Simulate a call to a michelson view
|
|
2248
2054
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2249
2055
|
*/
|
|
2250
|
-
runScriptView(
|
|
2251
|
-
return
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
}, Object.assign({ unparsing_mode }, rest));
|
|
2056
|
+
async runScriptView({ unparsing_mode = 'Readable', ...rest }, { block } = defaultRPCOptions) {
|
|
2057
|
+
return this.httpBackend.createRequest({
|
|
2058
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/run_script_view`),
|
|
2059
|
+
method: 'POST',
|
|
2060
|
+
}, {
|
|
2061
|
+
unparsing_mode,
|
|
2062
|
+
...rest,
|
|
2258
2063
|
});
|
|
2259
2064
|
}
|
|
2260
2065
|
/**
|
|
2261
2066
|
* @param viewParams Parameters of the view to run
|
|
2262
2067
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2263
|
-
*
|
|
2068
|
+
* Simulate a call to a view following the TZIP-4 standard.
|
|
2264
2069
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2265
2070
|
*/
|
|
2266
|
-
runView(
|
|
2267
|
-
return
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
}, Object.assign({ unparsing_mode }, rest));
|
|
2071
|
+
async runView({ unparsing_mode = 'Readable', ...rest }, { block } = defaultRPCOptions) {
|
|
2072
|
+
return this.httpBackend.createRequest({
|
|
2073
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/run_view`),
|
|
2074
|
+
method: 'POST',
|
|
2075
|
+
}, {
|
|
2076
|
+
unparsing_mode,
|
|
2077
|
+
...rest,
|
|
2274
2078
|
});
|
|
2275
2079
|
}
|
|
2276
|
-
getChainId() {
|
|
2277
|
-
return
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
method: 'GET',
|
|
2281
|
-
});
|
|
2080
|
+
async getChainId() {
|
|
2081
|
+
return this.httpBackend.createRequest({
|
|
2082
|
+
url: this.createURL(`/chains/${this.chain}/chain_id`),
|
|
2083
|
+
method: 'GET',
|
|
2282
2084
|
});
|
|
2283
2085
|
}
|
|
2284
2086
|
/**
|
|
2285
2087
|
* @param data Data to pack
|
|
2286
2088
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2287
|
-
*
|
|
2089
|
+
* Computes the serialized version of a data expression using the same algorithm as script instruction PACK
|
|
2288
2090
|
* Note: You should always verify the packed bytes before signing or requesting that they be signed when using the RPC to pack.
|
|
2289
2091
|
* This precaution helps protect you and your applications users from RPC nodes that have been compromised.
|
|
2290
2092
|
* A node that is operated by a bad actor, or compromised by a bad actor could return a fully formed operation that does not correspond to the input provided to the RPC endpoint.
|
|
@@ -2292,242 +2094,226 @@ class RpcClient {
|
|
|
2292
2094
|
* @example packData({ data: { string: "test" }, type: { prim: "string" } })
|
|
2293
2095
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2294
2096
|
*/
|
|
2295
|
-
packData(
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
return Object.assign({ gas: formattedGas }, rest);
|
|
2307
|
-
});
|
|
2097
|
+
async packData(data, { block } = defaultRPCOptions) {
|
|
2098
|
+
const { gas, ...rest } = await this.httpBackend.createRequest({
|
|
2099
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/pack_data`),
|
|
2100
|
+
method: 'POST',
|
|
2101
|
+
}, data);
|
|
2102
|
+
let formattedGas = gas;
|
|
2103
|
+
const tryBigNumber = new BigNumber(gas || '');
|
|
2104
|
+
if (!tryBigNumber.isNaN()) {
|
|
2105
|
+
formattedGas = tryBigNumber;
|
|
2106
|
+
}
|
|
2107
|
+
return { gas: formattedGas, ...rest };
|
|
2308
2108
|
}
|
|
2309
2109
|
/**
|
|
2310
2110
|
*
|
|
2311
|
-
*
|
|
2111
|
+
* Return rpc root url
|
|
2312
2112
|
*/
|
|
2313
2113
|
getRpcUrl() {
|
|
2314
2114
|
return this.url;
|
|
2315
2115
|
}
|
|
2316
2116
|
/**
|
|
2317
2117
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2318
|
-
*
|
|
2118
|
+
* Returns the voting period (index, kind, starting position) and related information (position, remaining) of the interrogated block
|
|
2319
2119
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-period
|
|
2320
2120
|
*/
|
|
2321
|
-
getCurrentPeriod() {
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
method: 'GET',
|
|
2326
|
-
});
|
|
2327
|
-
return response;
|
|
2121
|
+
async getCurrentPeriod({ block, } = defaultRPCOptions) {
|
|
2122
|
+
const response = await this.httpBackend.createRequest({
|
|
2123
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/current_period`),
|
|
2124
|
+
method: 'GET',
|
|
2328
2125
|
});
|
|
2126
|
+
return response;
|
|
2329
2127
|
}
|
|
2330
2128
|
/**
|
|
2331
2129
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2332
|
-
*
|
|
2130
|
+
* Returns the voting period (index, kind, starting position) and related information (position, remaining) of the next block.Useful to craft operations that will be valid in the next block
|
|
2333
2131
|
* @example getSuccessorPeriod() will default to successor voting period for /main/chains/block/head.
|
|
2334
2132
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-successor-period
|
|
2335
2133
|
*/
|
|
2336
|
-
getSuccessorPeriod() {
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
method: 'GET',
|
|
2341
|
-
});
|
|
2342
|
-
return response;
|
|
2134
|
+
async getSuccessorPeriod({ block, } = defaultRPCOptions) {
|
|
2135
|
+
const response = await this.httpBackend.createRequest({
|
|
2136
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/successor_period`),
|
|
2137
|
+
method: 'GET',
|
|
2343
2138
|
});
|
|
2139
|
+
return response;
|
|
2344
2140
|
}
|
|
2345
2141
|
/**
|
|
2346
2142
|
* @param id Sapling state ID
|
|
2347
2143
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2348
|
-
*
|
|
2144
|
+
* Returns the root and a diff of a state starting from an optional offset which is zero by default
|
|
2349
2145
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-sapling-sapling-state-id-get-diff
|
|
2350
2146
|
*/
|
|
2351
|
-
getSaplingDiffById(
|
|
2352
|
-
return
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
method: 'GET',
|
|
2356
|
-
});
|
|
2147
|
+
async getSaplingDiffById(id, { block } = defaultRPCOptions) {
|
|
2148
|
+
return this.httpBackend.createRequest({
|
|
2149
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/sapling/${id}/get_diff`),
|
|
2150
|
+
method: 'GET',
|
|
2357
2151
|
});
|
|
2358
2152
|
}
|
|
2359
2153
|
/**
|
|
2360
2154
|
* @param contract address of the contract we want to get the sapling diff
|
|
2361
2155
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2362
|
-
*
|
|
2156
|
+
* Returns the root and a diff of a state starting from an optional offset which is zero by default
|
|
2363
2157
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-single-sapling-get-diff
|
|
2364
2158
|
*/
|
|
2365
|
-
getSaplingDiffByContract(
|
|
2366
|
-
return
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
method: 'GET',
|
|
2370
|
-
});
|
|
2159
|
+
async getSaplingDiffByContract(contract, { block } = defaultRPCOptions) {
|
|
2160
|
+
return this.httpBackend.createRequest({
|
|
2161
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/single_sapling_get_diff`),
|
|
2162
|
+
method: 'GET',
|
|
2371
2163
|
});
|
|
2372
2164
|
}
|
|
2373
2165
|
/**
|
|
2374
2166
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2375
|
-
*
|
|
2167
|
+
* get current and next protocol
|
|
2376
2168
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-protocols
|
|
2377
2169
|
*/
|
|
2378
|
-
getProtocols() {
|
|
2379
|
-
return
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
method: 'GET',
|
|
2383
|
-
});
|
|
2170
|
+
async getProtocols({ block } = defaultRPCOptions) {
|
|
2171
|
+
return this.httpBackend.createRequest({
|
|
2172
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/protocols`),
|
|
2173
|
+
method: 'GET',
|
|
2384
2174
|
});
|
|
2385
2175
|
}
|
|
2386
2176
|
/**
|
|
2387
|
-
* @param
|
|
2388
|
-
*
|
|
2177
|
+
* @param protocol the protocol hash to look up (default to empty string)
|
|
2178
|
+
* get current and next protocol
|
|
2389
2179
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-protocols
|
|
2390
2180
|
*/
|
|
2391
|
-
getProtocolActivations() {
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
throw new InvalidProtocolHashError(protocol, protocolValidation);
|
|
2397
|
-
}
|
|
2181
|
+
async getProtocolActivations(protocol = '') {
|
|
2182
|
+
if (protocol) {
|
|
2183
|
+
const protocolValidation = validateProtocol(protocol);
|
|
2184
|
+
if (protocolValidation !== ValidationResult.VALID) {
|
|
2185
|
+
throw new InvalidProtocolHashError(protocol, protocolValidation);
|
|
2398
2186
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2187
|
+
}
|
|
2188
|
+
return this.httpBackend.createRequest({
|
|
2189
|
+
url: this.createURL(`/chains/${this.chain}/protocols/${protocol}`),
|
|
2190
|
+
method: 'GET',
|
|
2403
2191
|
});
|
|
2404
2192
|
}
|
|
2405
2193
|
/**
|
|
2406
2194
|
* @param contract address of the contract we want to retrieve storage information of
|
|
2407
2195
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2408
|
-
*
|
|
2196
|
+
* Access the used storage space of the contract
|
|
2409
2197
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2410
2198
|
*/
|
|
2411
|
-
getStorageUsedSpace(
|
|
2412
|
-
return
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
method: 'GET',
|
|
2416
|
-
});
|
|
2199
|
+
async getStorageUsedSpace(contract, { block } = defaultRPCOptions) {
|
|
2200
|
+
return this.httpBackend.createRequest({
|
|
2201
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/storage/used_space`),
|
|
2202
|
+
method: 'GET',
|
|
2417
2203
|
});
|
|
2418
2204
|
}
|
|
2419
2205
|
/**
|
|
2420
2206
|
* @param contract address of the contract we want to retrieve storage information of
|
|
2421
2207
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2422
|
-
*
|
|
2208
|
+
* Access the paid storage space of the contract
|
|
2423
2209
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
2424
2210
|
*/
|
|
2425
|
-
getStoragePaidSpace(
|
|
2426
|
-
return
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
method: 'GET',
|
|
2430
|
-
});
|
|
2211
|
+
async getStoragePaidSpace(contract, { block } = defaultRPCOptions) {
|
|
2212
|
+
return this.httpBackend.createRequest({
|
|
2213
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/storage/paid_space`),
|
|
2214
|
+
method: 'GET',
|
|
2431
2215
|
});
|
|
2432
2216
|
}
|
|
2433
2217
|
/**
|
|
2434
2218
|
* @param contract implicit or originated address we want to retrieve ticket balance of
|
|
2435
2219
|
* @param ticket object to specify a ticket by ticketer, content type and content
|
|
2436
2220
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2437
|
-
*
|
|
2221
|
+
* Access the contract's balance of ticket with specified ticketer, content type, and content.
|
|
2438
2222
|
* @example ticket { ticketer: 'address', content_type: { prim: "string" }, content: { string: 'ticket1' } }
|
|
2439
2223
|
* @see https://tezos.gitlab.io/protocols/016_mumbai.html#rpc-changes
|
|
2440
2224
|
*/
|
|
2441
|
-
getTicketBalance(
|
|
2442
|
-
return
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
}, ticket);
|
|
2447
|
-
});
|
|
2225
|
+
async getTicketBalance(contract, ticket, { block } = defaultRPCOptions) {
|
|
2226
|
+
return this.httpBackend.createRequest({
|
|
2227
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/ticket_balance`),
|
|
2228
|
+
method: 'POST',
|
|
2229
|
+
}, ticket);
|
|
2448
2230
|
}
|
|
2449
2231
|
/**
|
|
2450
2232
|
* @param contract originated address we want to retrieve ticket balances of
|
|
2451
2233
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2452
|
-
*
|
|
2234
|
+
* Access the complete list of tickets owned by the given contract by scanning the contract's storage.
|
|
2453
2235
|
* @see https://tezos.gitlab.io/protocols/016_mumbai.html#rpc-changes
|
|
2454
2236
|
*/
|
|
2455
|
-
getAllTicketBalances(
|
|
2456
|
-
return
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
method: 'GET',
|
|
2460
|
-
});
|
|
2237
|
+
async getAllTicketBalances(contract, { block } = defaultRPCOptions) {
|
|
2238
|
+
return this.httpBackend.createRequest({
|
|
2239
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/all_ticket_balances`),
|
|
2240
|
+
method: 'GET',
|
|
2461
2241
|
});
|
|
2462
2242
|
}
|
|
2463
2243
|
/**
|
|
2464
|
-
*
|
|
2244
|
+
* Returns the cycle at which the launch of the Adaptive Issuance feature is set to happen. A result of null means that the feature is not yet set to launch.
|
|
2465
2245
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2466
2246
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-adaptive-issuance-launch-cycle
|
|
2467
2247
|
*/
|
|
2468
|
-
getAdaptiveIssuanceLaunchCycle() {
|
|
2469
|
-
return
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
method: 'GET',
|
|
2473
|
-
});
|
|
2248
|
+
async getAdaptiveIssuanceLaunchCycle({ block, } = defaultRPCOptions) {
|
|
2249
|
+
return this.httpBackend.createRequest({
|
|
2250
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/adaptive_issuance_launch_cycle`),
|
|
2251
|
+
method: 'GET',
|
|
2474
2252
|
});
|
|
2475
2253
|
}
|
|
2476
2254
|
/**
|
|
2477
|
-
*
|
|
2255
|
+
* List the prevalidated operations in mempool (accessibility of mempool depends on each rpc endpoint)
|
|
2478
2256
|
* @param args has 5 optional properties
|
|
2479
2257
|
* @default args { version: '2', validated: true, refused: true, outdated, true, branchRefused: true, branchDelayed: true, validationPass: undefined, source: undefined, operationHash: undefined }
|
|
2480
2258
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/tallinn-mempool-openapi-rc.json
|
|
2481
2259
|
*/
|
|
2482
|
-
getPendingOperations() {
|
|
2483
|
-
return
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2260
|
+
async getPendingOperations(args = {}) {
|
|
2261
|
+
return this.httpBackend.createRequest({
|
|
2262
|
+
url: this.createURL(`/chains/${this.chain}/mempool/pending_operations`),
|
|
2263
|
+
method: 'GET',
|
|
2264
|
+
query: args,
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Returns the current mempool fee filter configuration.
|
|
2269
|
+
*
|
|
2270
|
+
* On Tezos L1 these values commonly resemble the historical fee defaults used by clients.
|
|
2271
|
+
* On Tezos X / Tezlink, the same fields are used for estimation but may differ materially,
|
|
2272
|
+
* especially the byte fee and the gas-price component.
|
|
2273
|
+
*
|
|
2274
|
+
* @param args optional query arguments for the mempool/filter endpoint
|
|
2275
|
+
*/
|
|
2276
|
+
async getMempoolFilter(args = {}) {
|
|
2277
|
+
return this.httpBackend.createRequest({
|
|
2278
|
+
url: this.createURL(`/chains/${this.chain}/mempool/filter`),
|
|
2279
|
+
method: 'GET',
|
|
2280
|
+
query: args,
|
|
2489
2281
|
});
|
|
2490
2282
|
}
|
|
2491
2283
|
/**
|
|
2492
2284
|
* @param delegate delegate address which we want to retrieve active staking parameters
|
|
2493
2285
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2494
|
-
*
|
|
2286
|
+
* Returns the currently active staking parameters for the given delegate
|
|
2495
2287
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-active-staking-parameters
|
|
2496
2288
|
*/
|
|
2497
|
-
getActiveStakingParameters(
|
|
2498
|
-
return
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
method: 'GET',
|
|
2502
|
-
});
|
|
2289
|
+
async getActiveStakingParameters(delegate, { block } = defaultRPCOptions) {
|
|
2290
|
+
return await this.httpBackend.createRequest({
|
|
2291
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates/${delegate}/active_staking_parameters`),
|
|
2292
|
+
method: 'GET',
|
|
2503
2293
|
});
|
|
2504
2294
|
}
|
|
2505
2295
|
/**
|
|
2506
2296
|
* @param delegate delegate address which we want to retrieve pending staking parameters
|
|
2507
2297
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2508
|
-
*
|
|
2298
|
+
* Returns the pending values for the given delegate's staking parameters
|
|
2509
2299
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-pending-staking-parameters
|
|
2510
2300
|
*/
|
|
2511
|
-
getPendingStakingParameters(
|
|
2512
|
-
return
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
method: 'GET',
|
|
2516
|
-
});
|
|
2301
|
+
async getPendingStakingParameters(delegate, { block } = defaultRPCOptions) {
|
|
2302
|
+
return await this.httpBackend.createRequest({
|
|
2303
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates/${delegate}/pending_staking_parameters`),
|
|
2304
|
+
method: 'GET',
|
|
2517
2305
|
});
|
|
2518
2306
|
}
|
|
2519
2307
|
/**
|
|
2520
2308
|
* @param destination address to retrieve the index for
|
|
2521
2309
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
2522
|
-
*
|
|
2310
|
+
* Returns the index assigned to the address if it was indexed by the opcode INDEX_ADDRESS, otherwise returns null
|
|
2523
2311
|
* @see https://octez.tezos.com/docs/alpha/rpc.html#get-block-id-context-destination-destination-id-index
|
|
2524
2312
|
*/
|
|
2525
|
-
getDestinationIndex(
|
|
2526
|
-
return
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
method: 'GET',
|
|
2530
|
-
});
|
|
2313
|
+
async getDestinationIndex(destination, { block } = defaultRPCOptions) {
|
|
2314
|
+
return await this.httpBackend.createRequest({
|
|
2315
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/destination/${destination}/index`),
|
|
2316
|
+
method: 'GET',
|
|
2531
2317
|
});
|
|
2532
2318
|
}
|
|
2533
2319
|
}
|