@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
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
3
|
exports.RpcClientCache = void 0;
|
|
24
4
|
const rpc_client_interface_1 = require("./../rpc-client-interface");
|
|
@@ -27,7 +7,7 @@ const core_1 = require("@taquito/core");
|
|
|
27
7
|
const utils_1 = require("@taquito/utils");
|
|
28
8
|
const defaultTtl = 1000;
|
|
29
9
|
/***
|
|
30
|
-
*
|
|
10
|
+
* RpcClientCache acts as a decorator over the RpcClient instance by caching responses for the period defined by the ttl.
|
|
31
11
|
*/
|
|
32
12
|
class RpcClientCache {
|
|
33
13
|
/**
|
|
@@ -46,7 +26,7 @@ class RpcClientCache {
|
|
|
46
26
|
return this._cache;
|
|
47
27
|
}
|
|
48
28
|
/**
|
|
49
|
-
*
|
|
29
|
+
* Remove all the data in the cache.
|
|
50
30
|
*
|
|
51
31
|
*/
|
|
52
32
|
deleteAllCachedData() {
|
|
@@ -97,819 +77,737 @@ class RpcClientCache {
|
|
|
97
77
|
}
|
|
98
78
|
/**
|
|
99
79
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
100
|
-
*
|
|
80
|
+
* Get the block's hash, its unique identifier.
|
|
101
81
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-hash
|
|
102
82
|
*/
|
|
103
|
-
getBlockHash() {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
});
|
|
83
|
+
async getBlockHash({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
84
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BLOCK_HASH, [
|
|
85
|
+
block,
|
|
86
|
+
]);
|
|
87
|
+
if (this.has(key)) {
|
|
88
|
+
return this.get(key);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const response = this.rpcClient.getBlockHash({ block });
|
|
92
|
+
this.put(key, response);
|
|
93
|
+
return response;
|
|
94
|
+
}
|
|
117
95
|
}
|
|
118
96
|
/**
|
|
119
97
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
120
|
-
*
|
|
98
|
+
* 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.
|
|
121
99
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-live-blocks
|
|
122
100
|
*/
|
|
123
|
-
getLiveBlocks() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
});
|
|
101
|
+
async getLiveBlocks({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
102
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_LIVE_BLOCKS, [
|
|
103
|
+
block,
|
|
104
|
+
]);
|
|
105
|
+
if (this.has(key)) {
|
|
106
|
+
return this.get(key);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const response = this.rpcClient.getLiveBlocks({ block });
|
|
110
|
+
this.put(key, response);
|
|
111
|
+
return response;
|
|
112
|
+
}
|
|
137
113
|
}
|
|
138
114
|
/**
|
|
139
115
|
* @param address address from which we want to retrieve the spendable balance
|
|
140
116
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
141
|
-
*
|
|
117
|
+
* 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.
|
|
142
118
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-balance
|
|
143
119
|
*/
|
|
144
|
-
getBalance(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
});
|
|
120
|
+
async getBalance(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
121
|
+
this.validateAddress(address);
|
|
122
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BALANCE, [
|
|
123
|
+
block,
|
|
124
|
+
address,
|
|
125
|
+
]);
|
|
126
|
+
if (this.has(key)) {
|
|
127
|
+
return this.get(key);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const response = this.rpcClient.getBalance(address, { block });
|
|
131
|
+
this.put(key, response);
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
160
134
|
}
|
|
161
135
|
/**
|
|
162
136
|
* @param address address from which we want to retrieve the balance
|
|
163
137
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
164
|
-
*
|
|
138
|
+
* 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.
|
|
165
139
|
*/
|
|
166
|
-
getSpendable(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
});
|
|
140
|
+
async getSpendable(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
141
|
+
this.validateAddress(address);
|
|
142
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_SPENDABLE, [
|
|
143
|
+
block,
|
|
144
|
+
address,
|
|
145
|
+
]);
|
|
146
|
+
if (this.has(key)) {
|
|
147
|
+
return this.get(key);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const response = this.rpcClient.getSpendable(address, { block });
|
|
151
|
+
this.put(key, response);
|
|
152
|
+
return response;
|
|
153
|
+
}
|
|
182
154
|
}
|
|
183
155
|
/**
|
|
184
156
|
* @param address address from which we want to retrieve balance and frozen bonds
|
|
185
157
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
186
|
-
*
|
|
158
|
+
* 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.
|
|
187
159
|
*/
|
|
188
|
-
getBalanceAndFrozenBonds(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
});
|
|
160
|
+
async getBalanceAndFrozenBonds(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
161
|
+
this.validateAddress(address);
|
|
162
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BALANCE_AND_FROZEN_BONDS, [block, address]);
|
|
163
|
+
if (this.has(key)) {
|
|
164
|
+
return this.get(key);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const response = this.rpcClient.getBalanceAndFrozenBonds(address, { block });
|
|
168
|
+
this.put(key, response);
|
|
169
|
+
return response;
|
|
170
|
+
}
|
|
201
171
|
}
|
|
202
172
|
/**
|
|
203
173
|
* @param address address from which we want to retrieve spendable and frozen bonds
|
|
204
174
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
205
|
-
*
|
|
175
|
+
* 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.
|
|
206
176
|
*/
|
|
207
|
-
getSpendableAndFrozenBonds(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
});
|
|
177
|
+
async getSpendableAndFrozenBonds(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
178
|
+
this.validateAddress(address);
|
|
179
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_SPENDABLE_AND_FROZEN_BONDS, [block, address]);
|
|
180
|
+
if (this.has(key)) {
|
|
181
|
+
return this.get(key);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const response = this.rpcClient.getSpendableAndFrozenBonds(address, { block });
|
|
185
|
+
this.put(key, response);
|
|
186
|
+
return response;
|
|
187
|
+
}
|
|
220
188
|
}
|
|
221
189
|
/**
|
|
222
190
|
* @param address address from which we want to retrieve the full balance
|
|
223
191
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
224
|
-
*
|
|
192
|
+
* Access the full balance of a contract, including frozen bonds and stake.
|
|
225
193
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-full-balance
|
|
226
194
|
*/
|
|
227
|
-
getFullBalance(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
});
|
|
195
|
+
async getFullBalance(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
196
|
+
this.validateAddress(address);
|
|
197
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_FULL_BALANCE, [
|
|
198
|
+
block,
|
|
199
|
+
address,
|
|
200
|
+
]);
|
|
201
|
+
if (this.has(key)) {
|
|
202
|
+
return this.get(key);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
const response = this.rpcClient.getFullBalance(address, { block });
|
|
206
|
+
this.put(key, response);
|
|
207
|
+
return response;
|
|
208
|
+
}
|
|
243
209
|
}
|
|
244
210
|
/**
|
|
245
211
|
* @param address address from which we want to retrieve the staked balance
|
|
246
212
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
247
|
-
*
|
|
213
|
+
* Access the staked balance of a contract. Returns None if the contract is originated, or neither delegated nor a delegate.
|
|
248
214
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-staked-balance
|
|
249
215
|
*/
|
|
250
|
-
getStakedBalance(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
});
|
|
216
|
+
async getStakedBalance(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
217
|
+
this.validateAddress(address);
|
|
218
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_STAKED_BALANCE, [
|
|
219
|
+
block,
|
|
220
|
+
address,
|
|
221
|
+
]);
|
|
222
|
+
if (this.has(key)) {
|
|
223
|
+
return this.get(key);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const response = this.rpcClient.getStakedBalance(address, { block });
|
|
227
|
+
this.put(key, response);
|
|
228
|
+
return response;
|
|
229
|
+
}
|
|
266
230
|
}
|
|
267
231
|
/**
|
|
268
232
|
* @param address address from which we want to retrieve the unstaked finalizable balance
|
|
269
233
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
270
|
-
*
|
|
234
|
+
* 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.
|
|
271
235
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstaked-finalizable-balance
|
|
272
236
|
*/
|
|
273
|
-
getUnstakedFinalizableBalance(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
});
|
|
237
|
+
async getUnstakedFinalizableBalance(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
238
|
+
this.validateAddress(address);
|
|
239
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_UNSTAKED_FINALIZABLE_BALANCE, [block, address]);
|
|
240
|
+
if (this.has(key)) {
|
|
241
|
+
return this.get(key);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
const response = this.rpcClient.getUnstakedFinalizableBalance(address, { block });
|
|
245
|
+
this.put(key, response);
|
|
246
|
+
return response;
|
|
247
|
+
}
|
|
286
248
|
}
|
|
287
249
|
/**
|
|
288
250
|
* @param address address from which we want to retrieve the unstaked frozen balance
|
|
289
251
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
290
|
-
*
|
|
252
|
+
* 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.
|
|
291
253
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstaked-frozen-balance
|
|
292
254
|
*/
|
|
293
|
-
getUnstakedFrozenBalance(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
});
|
|
255
|
+
async getUnstakedFrozenBalance(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
256
|
+
this.validateAddress(address);
|
|
257
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_UNSTAKED_FROZEN_BALANCE, [block, address]);
|
|
258
|
+
if (this.has(key)) {
|
|
259
|
+
return this.get(key);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
const response = this.rpcClient.getUnstakedFrozenBalance(address, { block });
|
|
263
|
+
this.put(key, response);
|
|
264
|
+
return response;
|
|
265
|
+
}
|
|
306
266
|
}
|
|
307
267
|
/**
|
|
308
268
|
* @param address address from which we want to retrieve the unstake requests
|
|
309
269
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
310
|
-
*
|
|
270
|
+
* 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.
|
|
311
271
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstake-requests
|
|
312
272
|
*/
|
|
313
|
-
getUnstakeRequests(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
});
|
|
273
|
+
async getUnstakeRequests(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
274
|
+
this.validateAddress(address);
|
|
275
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_UNSTAKE_REQUESTS, [block, address]);
|
|
276
|
+
if (this.has(key)) {
|
|
277
|
+
return this.get(key);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
const response = this.rpcClient.getUnstakeRequests(address, { block });
|
|
281
|
+
this.put(key, response);
|
|
282
|
+
return response;
|
|
283
|
+
}
|
|
326
284
|
}
|
|
327
285
|
/**
|
|
328
286
|
* @param address contract address from which we want to retrieve the storage
|
|
329
287
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
330
|
-
*
|
|
288
|
+
* Access the data of the contract.
|
|
331
289
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-storage
|
|
332
290
|
*/
|
|
333
|
-
getStorage(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
});
|
|
291
|
+
async getStorage(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
292
|
+
this.validateContract(address);
|
|
293
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_STORAGE, [
|
|
294
|
+
block,
|
|
295
|
+
address,
|
|
296
|
+
]);
|
|
297
|
+
if (this.has(key)) {
|
|
298
|
+
return this.get(key);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
const response = this.rpcClient.getStorage(address, { block });
|
|
302
|
+
this.put(key, response);
|
|
303
|
+
return response;
|
|
304
|
+
}
|
|
349
305
|
}
|
|
350
306
|
/**
|
|
351
307
|
* @param address contract address from which we want to retrieve the script
|
|
352
308
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
353
|
-
*
|
|
309
|
+
* Access the code and data of the contract.
|
|
354
310
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-script
|
|
355
311
|
*/
|
|
356
|
-
getScript(
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
});
|
|
312
|
+
async getScript(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
313
|
+
this.validateContract(address);
|
|
314
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_SCRIPT, [
|
|
315
|
+
block,
|
|
316
|
+
address,
|
|
317
|
+
]);
|
|
318
|
+
if (this.has(key)) {
|
|
319
|
+
return this.get(key);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
const response = this.rpcClient.getScript(address, { block });
|
|
323
|
+
this.put(key, response);
|
|
324
|
+
return response;
|
|
325
|
+
}
|
|
372
326
|
}
|
|
373
327
|
/**
|
|
374
328
|
* @param address contract address from which we want to retrieve the script
|
|
375
329
|
* @param unparsingMode default is { unparsing_mode: "Readable" }
|
|
376
330
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
377
|
-
*
|
|
331
|
+
* Access the script of the contract and normalize it using the requested unparsing mode.
|
|
378
332
|
*/
|
|
379
|
-
getNormalizedScript(
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
});
|
|
333
|
+
async getNormalizedScript(address, unparsingMode = { unparsing_mode: 'Readable' }, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
334
|
+
this.validateContract(address);
|
|
335
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_NORMALIZED_SCRIPT, [block, address], unparsingMode);
|
|
336
|
+
if (this.has(key)) {
|
|
337
|
+
return this.get(key);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
const response = this.rpcClient.getNormalizedScript(address, unparsingMode, { block });
|
|
341
|
+
this.put(key, response);
|
|
342
|
+
return response;
|
|
343
|
+
}
|
|
392
344
|
}
|
|
393
345
|
/**
|
|
394
346
|
* @param address contract address from which we want to retrieve
|
|
395
347
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
396
|
-
*
|
|
348
|
+
* Access the complete status of a contract.
|
|
397
349
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id
|
|
398
350
|
*/
|
|
399
|
-
getContract(
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
});
|
|
351
|
+
async getContract(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
352
|
+
this.validateAddress(address);
|
|
353
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_CONTRACT, [
|
|
354
|
+
block,
|
|
355
|
+
address,
|
|
356
|
+
]);
|
|
357
|
+
if (this.has(key)) {
|
|
358
|
+
return this.get(key);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
const response = this.rpcClient.getContract(address, { block });
|
|
362
|
+
this.put(key, response);
|
|
363
|
+
return response;
|
|
364
|
+
}
|
|
415
365
|
}
|
|
416
366
|
/**
|
|
417
367
|
* @param address contract address from which we want to retrieve the manager
|
|
418
368
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
419
|
-
*
|
|
369
|
+
* Access the manager of an implicit contract
|
|
420
370
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-manager-key
|
|
421
371
|
*/
|
|
422
|
-
getManagerKey(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
});
|
|
372
|
+
async getManagerKey(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
373
|
+
this.validateAddress(address);
|
|
374
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_MANAGER_KEY, [
|
|
375
|
+
block,
|
|
376
|
+
address,
|
|
377
|
+
]);
|
|
378
|
+
if (this.has(key)) {
|
|
379
|
+
return this.get(key);
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
const response = this.rpcClient.getManagerKey(address, { block });
|
|
383
|
+
this.put(key, response);
|
|
384
|
+
return response;
|
|
385
|
+
}
|
|
438
386
|
}
|
|
439
387
|
/**
|
|
440
388
|
* @param address contract address from which we want to retrieve the delegate (baker)
|
|
441
389
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
442
|
-
*
|
|
390
|
+
* Access the delegate of a contract, if any
|
|
443
391
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-delegate
|
|
444
392
|
*/
|
|
445
|
-
getDelegate(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
});
|
|
393
|
+
async getDelegate(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
394
|
+
this.validateAddress(address);
|
|
395
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_DELEGATE, [
|
|
396
|
+
block,
|
|
397
|
+
address,
|
|
398
|
+
]);
|
|
399
|
+
if (this.has(key)) {
|
|
400
|
+
return this.get(key);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
const response = this.rpcClient.getDelegate(address, { block });
|
|
404
|
+
this.put(key, response);
|
|
405
|
+
return response;
|
|
406
|
+
}
|
|
461
407
|
}
|
|
462
408
|
/**
|
|
463
409
|
* @param id Big Map ID
|
|
464
410
|
* @param expr Expression hash to query (A b58check encoded Blake2b hash of the expression (The expression can be packed using the pack_data method))
|
|
465
411
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
466
|
-
*
|
|
412
|
+
* Access the value associated with a key in a big map.
|
|
467
413
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-big-maps-big-map-id-script-expr
|
|
468
414
|
*/
|
|
469
|
-
getBigMapExpr(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
});
|
|
415
|
+
async getBigMapExpr(id, expr, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
416
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BIG_MAP_EXPR, [
|
|
417
|
+
block,
|
|
418
|
+
id,
|
|
419
|
+
expr,
|
|
420
|
+
]);
|
|
421
|
+
if (this.has(key)) {
|
|
422
|
+
return this.get(key);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
const response = this.rpcClient.getBigMapExpr(id, expr, { block });
|
|
426
|
+
this.put(key, response);
|
|
427
|
+
return response;
|
|
428
|
+
}
|
|
485
429
|
}
|
|
486
430
|
/**
|
|
487
431
|
* @param args contains optional query arguments (active, inactive, with_minimal_stake, without_minimal_stake)
|
|
488
432
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
489
|
-
*
|
|
433
|
+
* Lists all registered delegates by default with query arguments to filter unneeded values.
|
|
490
434
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh
|
|
491
435
|
*/
|
|
492
|
-
getAllDelegates() {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
});
|
|
436
|
+
async getAllDelegates(args = {}, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
437
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_ALL_DELEGATES, [
|
|
438
|
+
block,
|
|
439
|
+
args,
|
|
440
|
+
]);
|
|
441
|
+
if (this.has(key)) {
|
|
442
|
+
return this.get(key);
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
const response = this.rpcClient.getAllDelegates(args, { block });
|
|
446
|
+
this.put(key, response);
|
|
447
|
+
return response;
|
|
448
|
+
}
|
|
507
449
|
}
|
|
508
450
|
/**
|
|
509
451
|
* @param address delegate address which we want to retrieve
|
|
510
452
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
511
|
-
*
|
|
453
|
+
* Everything about a delegate
|
|
512
454
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh
|
|
513
455
|
*/
|
|
514
|
-
getDelegates(
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
});
|
|
456
|
+
async getDelegates(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
457
|
+
this.validateAddress(address);
|
|
458
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_DELEGATES, [
|
|
459
|
+
block,
|
|
460
|
+
address,
|
|
461
|
+
]);
|
|
462
|
+
if (this.has(key)) {
|
|
463
|
+
return this.get(key);
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
const response = this.rpcClient.getDelegates(address, { block });
|
|
467
|
+
this.put(key, response);
|
|
468
|
+
return response;
|
|
469
|
+
}
|
|
530
470
|
}
|
|
531
471
|
/**
|
|
532
472
|
* @param address delegate address which we want to retrieve
|
|
533
473
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
534
|
-
*
|
|
474
|
+
* Returns the delegate info (e.g. voting power) found in the listings of the current voting period
|
|
535
475
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-voting-info
|
|
536
476
|
*/
|
|
537
|
-
getVotingInfo(
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
});
|
|
477
|
+
async getVotingInfo(address, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
478
|
+
this.validateAddress(address);
|
|
479
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_VOTING_INFO, [
|
|
480
|
+
block,
|
|
481
|
+
address,
|
|
482
|
+
]);
|
|
483
|
+
if (this.has(key)) {
|
|
484
|
+
return this.get(key);
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
const response = this.rpcClient.getVotingInfo(address, { block });
|
|
488
|
+
this.put(key, response);
|
|
489
|
+
return response;
|
|
490
|
+
}
|
|
553
491
|
}
|
|
554
492
|
/**
|
|
555
493
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
556
|
-
*
|
|
494
|
+
* All constants
|
|
557
495
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-constants
|
|
558
496
|
*/
|
|
559
|
-
getConstants() {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
});
|
|
497
|
+
async getConstants({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
498
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_CONSTANTS, [
|
|
499
|
+
block,
|
|
500
|
+
]);
|
|
501
|
+
if (this.has(key)) {
|
|
502
|
+
return this.get(key);
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
const response = this.rpcClient.getConstants({ block });
|
|
506
|
+
this.put(key, response);
|
|
507
|
+
return response;
|
|
508
|
+
}
|
|
573
509
|
}
|
|
574
510
|
/**
|
|
575
511
|
* @param options contains generic configuration for rpc calls to specified block (default to head) and version.
|
|
576
|
-
*
|
|
512
|
+
* All the information about a block
|
|
577
513
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id
|
|
578
514
|
* @example getBlock() will default to `/main/chains/block/head?version=1`
|
|
579
515
|
* @example getBlock({ block: 'head~2') will return an offset of 2 from head blocks
|
|
580
516
|
* @example getBlock({ block: 'BL8fTiWcSxWCjiMVnDkbh6EuhqVPZzgWheJ2dqwrxYRm9AephXh~2' }) will return an offset of 2 blocks from given block hash..
|
|
581
517
|
*/
|
|
582
|
-
getBlock() {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}
|
|
593
|
-
});
|
|
518
|
+
async getBlock({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
519
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BLOCK, [block]);
|
|
520
|
+
if (this.has(key)) {
|
|
521
|
+
return this.get(key);
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
const response = this.rpcClient.getBlock({ block });
|
|
525
|
+
this.put(key, response);
|
|
526
|
+
return response;
|
|
527
|
+
}
|
|
594
528
|
}
|
|
595
529
|
/**
|
|
596
530
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
597
|
-
*
|
|
531
|
+
* The whole block header
|
|
598
532
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-header
|
|
599
533
|
*/
|
|
600
|
-
getBlockHeader() {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
});
|
|
534
|
+
async getBlockHeader({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
535
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BLOCK_HEADER, [
|
|
536
|
+
block,
|
|
537
|
+
]);
|
|
538
|
+
if (this.has(key)) {
|
|
539
|
+
return this.get(key);
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
const response = this.rpcClient.getBlockHeader({ block });
|
|
543
|
+
this.put(key, response);
|
|
544
|
+
return response;
|
|
545
|
+
}
|
|
614
546
|
}
|
|
615
547
|
/**
|
|
616
548
|
* @param options contains generic configuration for rpc calls to specified block (default to head) and version
|
|
617
|
-
*
|
|
549
|
+
* All the metadata associated to the block
|
|
618
550
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-metadata
|
|
619
551
|
*/
|
|
620
|
-
getBlockMetadata() {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
});
|
|
552
|
+
async getBlockMetadata({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
553
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BLOCK_METADATA, [
|
|
554
|
+
block,
|
|
555
|
+
]);
|
|
556
|
+
if (this.has(key)) {
|
|
557
|
+
return this.get(key);
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
const response = this.rpcClient.getBlockMetadata({ block });
|
|
561
|
+
this.put(key, response);
|
|
562
|
+
return response;
|
|
563
|
+
}
|
|
634
564
|
}
|
|
635
565
|
/**
|
|
636
566
|
* @param args contains optional query arguments (level, cycle, delegate, consensus_key, and max_round)
|
|
637
567
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
638
|
-
*
|
|
568
|
+
* Retrieves the list of delegates allowed to bake a block.
|
|
639
569
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
640
570
|
*/
|
|
641
|
-
getBakingRights() {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
});
|
|
571
|
+
async getBakingRights(args = {}, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
572
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BAKING_RIGHTS, [
|
|
573
|
+
block,
|
|
574
|
+
args,
|
|
575
|
+
]);
|
|
576
|
+
if (this.has(key)) {
|
|
577
|
+
return this.get(key);
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
const response = this.rpcClient.getBakingRights(args, { block });
|
|
581
|
+
this.put(key, response);
|
|
582
|
+
return response;
|
|
583
|
+
}
|
|
656
584
|
}
|
|
657
585
|
/**
|
|
658
586
|
* @param args contains optional query arguments (level, cycle, delegate, and consensus_key)
|
|
659
587
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
660
|
-
*
|
|
588
|
+
* Retrieves the delegates allowed to attest a block
|
|
661
589
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
662
590
|
*/
|
|
663
|
-
getAttestationRights() {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
}
|
|
674
|
-
});
|
|
591
|
+
async getAttestationRights(args = {}, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
592
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_ATTESTATION_RIGHTS, [block, args]);
|
|
593
|
+
if (this.has(key)) {
|
|
594
|
+
return this.get(key);
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
const response = this.rpcClient.getAttestationRights(args, { block });
|
|
598
|
+
this.put(key, response);
|
|
599
|
+
return response;
|
|
600
|
+
}
|
|
675
601
|
}
|
|
676
602
|
/**
|
|
677
603
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
678
|
-
*
|
|
604
|
+
* Ballots casted so far during a voting period
|
|
679
605
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-ballot-list
|
|
680
606
|
*/
|
|
681
|
-
getBallotList() {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
});
|
|
607
|
+
async getBallotList({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
608
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BALLOT_LIST, [
|
|
609
|
+
block,
|
|
610
|
+
]);
|
|
611
|
+
if (this.has(key)) {
|
|
612
|
+
return this.get(key);
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
const response = this.rpcClient.getBallotList({ block });
|
|
616
|
+
this.put(key, response);
|
|
617
|
+
return response;
|
|
618
|
+
}
|
|
695
619
|
}
|
|
696
620
|
/**
|
|
697
621
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
698
|
-
*
|
|
622
|
+
* Sum of ballots casted so far during a voting period
|
|
699
623
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-ballots
|
|
700
624
|
*/
|
|
701
|
-
getBallots() {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
});
|
|
625
|
+
async getBallots({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
626
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_BALLOTS, [block]);
|
|
627
|
+
if (this.has(key)) {
|
|
628
|
+
return this.get(key);
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
const response = this.rpcClient.getBallots({ block });
|
|
632
|
+
this.put(key, response);
|
|
633
|
+
return response;
|
|
634
|
+
}
|
|
713
635
|
}
|
|
714
636
|
/**
|
|
715
637
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
716
|
-
*
|
|
638
|
+
* Current proposal under evaluation.
|
|
717
639
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-proposal
|
|
718
640
|
*/
|
|
719
|
-
getCurrentProposal() {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
730
|
-
});
|
|
641
|
+
async getCurrentProposal({ block, } = rpc_client_interface_2.defaultRPCOptions) {
|
|
642
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_CURRENT_PROPOSAL, [block]);
|
|
643
|
+
if (this.has(key)) {
|
|
644
|
+
return this.get(key);
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
const response = this.rpcClient.getCurrentProposal({ block });
|
|
648
|
+
this.put(key, response);
|
|
649
|
+
return response;
|
|
650
|
+
}
|
|
731
651
|
}
|
|
732
652
|
/**
|
|
733
653
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
734
|
-
*
|
|
654
|
+
* Current expected quorum.
|
|
735
655
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-quorum
|
|
736
656
|
*/
|
|
737
|
-
getCurrentQuorum() {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
}
|
|
750
|
-
});
|
|
657
|
+
async getCurrentQuorum({ block, } = rpc_client_interface_2.defaultRPCOptions) {
|
|
658
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_CURRENT_QUORUM, [
|
|
659
|
+
block,
|
|
660
|
+
]);
|
|
661
|
+
if (this.has(key)) {
|
|
662
|
+
return this.get(key);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
const response = this.rpcClient.getCurrentQuorum({ block });
|
|
666
|
+
this.put(key, response);
|
|
667
|
+
return response;
|
|
668
|
+
}
|
|
751
669
|
}
|
|
752
670
|
/**
|
|
753
671
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
754
|
-
*
|
|
672
|
+
* List of delegates with their voting power
|
|
755
673
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-listings
|
|
756
674
|
*/
|
|
757
|
-
getVotesListings() {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
}
|
|
770
|
-
});
|
|
675
|
+
async getVotesListings({ block, } = rpc_client_interface_2.defaultRPCOptions) {
|
|
676
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_VOTES_LISTINGS, [
|
|
677
|
+
block,
|
|
678
|
+
]);
|
|
679
|
+
if (this.has(key)) {
|
|
680
|
+
return this.get(key);
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
const response = this.rpcClient.getVotesListings({ block });
|
|
684
|
+
this.put(key, response);
|
|
685
|
+
return response;
|
|
686
|
+
}
|
|
771
687
|
}
|
|
772
688
|
/**
|
|
773
689
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
774
|
-
*
|
|
690
|
+
* List of proposals with number of supporters
|
|
775
691
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-proposals
|
|
776
692
|
*/
|
|
777
|
-
getProposals() {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
});
|
|
693
|
+
async getProposals({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
694
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_PROPOSALS, [
|
|
695
|
+
block,
|
|
696
|
+
]);
|
|
697
|
+
if (this.has(key)) {
|
|
698
|
+
return this.get(key);
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
const response = this.rpcClient.getProposals({ block });
|
|
702
|
+
this.put(key, response);
|
|
703
|
+
return response;
|
|
704
|
+
}
|
|
791
705
|
}
|
|
792
706
|
/**
|
|
793
707
|
* @param data operation contents to forge
|
|
794
708
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
795
|
-
*
|
|
709
|
+
* Forge an operation returning the unsigned bytes
|
|
796
710
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
797
711
|
*/
|
|
798
|
-
forgeOperations(
|
|
799
|
-
return
|
|
800
|
-
return this.rpcClient.forgeOperations(data, { block });
|
|
801
|
-
});
|
|
712
|
+
async forgeOperations(data, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
713
|
+
return this.rpcClient.forgeOperations(data, { block });
|
|
802
714
|
}
|
|
803
715
|
/**
|
|
804
716
|
* @param signedOpBytes signed bytes to inject
|
|
805
|
-
*
|
|
717
|
+
* Inject an operation in node and broadcast it and return the ID of the operation
|
|
806
718
|
* @see https://tezos.gitlab.io/shell/rpc.html#post-injection-operation
|
|
807
719
|
*/
|
|
808
|
-
injectOperation(signedOpBytes) {
|
|
809
|
-
return
|
|
810
|
-
return this.rpcClient.injectOperation(signedOpBytes);
|
|
811
|
-
});
|
|
720
|
+
async injectOperation(signedOpBytes) {
|
|
721
|
+
return this.rpcClient.injectOperation(signedOpBytes);
|
|
812
722
|
}
|
|
813
723
|
/**
|
|
814
724
|
* @param ops Operations to apply
|
|
815
725
|
* @param options contains generic configuration for rpc calls to specified block and version
|
|
816
|
-
*
|
|
726
|
+
* Simulate the application of the operations with the context of the given block and return the result of each operation application
|
|
817
727
|
* @see https://tezos.gitlab.io/active/rpc.html#post-block-id-helpers-preapply-operations
|
|
818
728
|
*/
|
|
819
|
-
preapplyOperations(
|
|
820
|
-
return
|
|
821
|
-
return this.rpcClient.preapplyOperations(ops, { block });
|
|
822
|
-
});
|
|
729
|
+
async preapplyOperations(ops, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
730
|
+
return this.rpcClient.preapplyOperations(ops, { block });
|
|
823
731
|
}
|
|
824
732
|
/**
|
|
825
733
|
* @param contract address of the contract we want to get the entrypoints of
|
|
826
734
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
827
|
-
*
|
|
735
|
+
* Return the list of entrypoints of the contract
|
|
828
736
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-entrypoints
|
|
829
|
-
* @version 005_PsBABY5H
|
|
737
|
+
* @remarks version 005_PsBABY5H
|
|
830
738
|
*/
|
|
831
|
-
getEntrypoints(
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
}
|
|
846
|
-
});
|
|
739
|
+
async getEntrypoints(contract, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
740
|
+
this.validateContract(contract);
|
|
741
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_ENTRYPOINTS, [
|
|
742
|
+
block,
|
|
743
|
+
contract,
|
|
744
|
+
]);
|
|
745
|
+
if (this.has(key)) {
|
|
746
|
+
return this.get(key);
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
const response = this.rpcClient.getEntrypoints(contract, { block });
|
|
750
|
+
this.put(key, response);
|
|
751
|
+
return response;
|
|
752
|
+
}
|
|
847
753
|
}
|
|
848
754
|
/**
|
|
849
755
|
* @param op Operation to simulate
|
|
850
756
|
* @param options contains generic configuration for rpc calls to specified block and version
|
|
851
|
-
*
|
|
757
|
+
* 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.
|
|
852
758
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
853
759
|
*/
|
|
854
|
-
simulateOperation(
|
|
855
|
-
return
|
|
856
|
-
return this.rpcClient.simulateOperation(op, { block });
|
|
857
|
-
});
|
|
760
|
+
async simulateOperation(op, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
761
|
+
return this.rpcClient.simulateOperation(op, { block });
|
|
858
762
|
}
|
|
859
763
|
/**
|
|
860
764
|
* @param code Code to run
|
|
861
765
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
862
|
-
*
|
|
766
|
+
* Run a Michelson script in the current context
|
|
863
767
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
864
768
|
*/
|
|
865
|
-
runCode(
|
|
866
|
-
return
|
|
867
|
-
return this.rpcClient.runCode(code, { block });
|
|
868
|
-
});
|
|
769
|
+
async runCode(code, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
770
|
+
return this.rpcClient.runCode(code, { block });
|
|
869
771
|
}
|
|
870
772
|
/**
|
|
871
773
|
* @param viewScriptParams Parameters of the script view to run
|
|
872
774
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
873
|
-
*
|
|
775
|
+
* Simulate a call to a michelson view
|
|
874
776
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
875
777
|
*/
|
|
876
|
-
runScriptView(
|
|
877
|
-
return
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
});
|
|
778
|
+
async runScriptView({ unparsing_mode = 'Readable', ...rest }, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
779
|
+
return this.rpcClient.runScriptView({
|
|
780
|
+
unparsing_mode,
|
|
781
|
+
...rest,
|
|
782
|
+
}, { block });
|
|
882
783
|
}
|
|
883
784
|
/**
|
|
884
785
|
* @param viewParams Parameters of the view to run
|
|
885
786
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
886
|
-
*
|
|
787
|
+
* Simulate a call to a view following the TZIP-4 standard.
|
|
887
788
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
888
789
|
*/
|
|
889
|
-
runView(
|
|
890
|
-
return
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
return response;
|
|
906
|
-
}
|
|
907
|
-
});
|
|
790
|
+
async runView({ unparsing_mode = 'Readable', ...rest }, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
791
|
+
return this.rpcClient.runView({
|
|
792
|
+
unparsing_mode,
|
|
793
|
+
...rest,
|
|
794
|
+
}, { block });
|
|
795
|
+
}
|
|
796
|
+
async getChainId() {
|
|
797
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_CHAIN_ID, []);
|
|
798
|
+
if (this.has(key)) {
|
|
799
|
+
return this.get(key);
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
const response = this.rpcClient.getChainId();
|
|
803
|
+
this.put(key, response);
|
|
804
|
+
return response;
|
|
805
|
+
}
|
|
908
806
|
}
|
|
909
807
|
/**
|
|
910
808
|
* @param data Data to pack
|
|
911
809
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
912
|
-
*
|
|
810
|
+
* Computes the serialized version of a data expression using the same algorithm as script instruction PACK
|
|
913
811
|
* Note: You should always verify the packed bytes before signing or requesting that they be signed when using the RPC to pack.
|
|
914
812
|
* This precaution helps protect you and your applications users from RPC nodes that have been compromised.
|
|
915
813
|
* 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.
|
|
@@ -917,319 +815,304 @@ class RpcClientCache {
|
|
|
917
815
|
* @example packData({ data: { string: "test" }, type: { prim: "string" } })
|
|
918
816
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
919
817
|
*/
|
|
920
|
-
packData(
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
}
|
|
931
|
-
});
|
|
818
|
+
async packData(data, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
819
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.PACK_DATA, [block], data);
|
|
820
|
+
if (this.has(key)) {
|
|
821
|
+
return this.get(key);
|
|
822
|
+
}
|
|
823
|
+
else {
|
|
824
|
+
const response = this.rpcClient.packData(data, { block });
|
|
825
|
+
this.put(key, response);
|
|
826
|
+
return response;
|
|
827
|
+
}
|
|
932
828
|
}
|
|
933
829
|
/**
|
|
934
830
|
*
|
|
935
|
-
*
|
|
831
|
+
* Return rpc root url
|
|
936
832
|
*/
|
|
937
833
|
getRpcUrl() {
|
|
938
834
|
return this.rpcClient.getRpcUrl();
|
|
939
835
|
}
|
|
940
836
|
/**
|
|
941
837
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
942
|
-
*
|
|
838
|
+
* Returns the voting period (index, kind, starting position) and related information (position, remaining) of the interrogated block
|
|
943
839
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-period
|
|
944
840
|
*/
|
|
945
|
-
getCurrentPeriod() {
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
}
|
|
958
|
-
});
|
|
841
|
+
async getCurrentPeriod({ block, } = rpc_client_interface_2.defaultRPCOptions) {
|
|
842
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_CURRENT_PERIOD, [
|
|
843
|
+
block,
|
|
844
|
+
]);
|
|
845
|
+
if (this.has(key)) {
|
|
846
|
+
return this.get(key);
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
const response = this.rpcClient.getCurrentPeriod({ block });
|
|
850
|
+
this.put(key, response);
|
|
851
|
+
return response;
|
|
852
|
+
}
|
|
959
853
|
}
|
|
960
854
|
/**
|
|
961
855
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
962
|
-
*
|
|
856
|
+
* 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
|
|
963
857
|
* @example getSuccessorPeriod() will default to successor voting period for /main/chains/block/head.
|
|
964
858
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-successor-period
|
|
965
859
|
*/
|
|
966
|
-
getSuccessorPeriod() {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
}
|
|
977
|
-
});
|
|
860
|
+
async getSuccessorPeriod({ block, } = rpc_client_interface_2.defaultRPCOptions) {
|
|
861
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_SUCCESSOR_PERIOD, [block]);
|
|
862
|
+
if (this.has(key)) {
|
|
863
|
+
return this.get(key);
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
const response = this.rpcClient.getSuccessorPeriod({ block });
|
|
867
|
+
this.put(key, response);
|
|
868
|
+
return response;
|
|
869
|
+
}
|
|
978
870
|
}
|
|
979
871
|
/**
|
|
980
872
|
* @param id Sapling state ID
|
|
981
873
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
982
|
-
*
|
|
874
|
+
* Returns the root and a diff of a state starting from an optional offset which is zero by default
|
|
983
875
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-sapling-sapling-state-id-get-diff
|
|
984
876
|
*/
|
|
985
|
-
getSaplingDiffById(
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
}
|
|
996
|
-
});
|
|
877
|
+
async getSaplingDiffById(id, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
878
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_SAPLING_DIFF_BY_ID, [block, id]);
|
|
879
|
+
if (this.has(key)) {
|
|
880
|
+
return this.get(key);
|
|
881
|
+
}
|
|
882
|
+
else {
|
|
883
|
+
const response = this.rpcClient.getSaplingDiffById(id, { block });
|
|
884
|
+
this.put(key, response);
|
|
885
|
+
return response;
|
|
886
|
+
}
|
|
997
887
|
}
|
|
998
888
|
/**
|
|
999
889
|
* @param contract address of the contract we want to get the sapling diff
|
|
1000
890
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1001
|
-
*
|
|
891
|
+
* Returns the root and a diff of a state starting from an optional offset which is zero by default
|
|
1002
892
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-single-sapling-get-diff
|
|
1003
893
|
*/
|
|
1004
|
-
getSaplingDiffByContract(
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
894
|
+
async getSaplingDiffByContract(contract, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
895
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_SAPLING_DIFF_BY_CONTRACT, [block, contract]);
|
|
896
|
+
if (this.has(key)) {
|
|
897
|
+
return this.get(key);
|
|
898
|
+
}
|
|
899
|
+
else {
|
|
900
|
+
const response = this.rpcClient.getSaplingDiffByContract(contract, { block });
|
|
901
|
+
this.put(key, response);
|
|
902
|
+
return response;
|
|
903
|
+
}
|
|
1016
904
|
}
|
|
1017
905
|
/**
|
|
1018
906
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1019
|
-
*
|
|
907
|
+
* get current and next protocol
|
|
1020
908
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-protocols
|
|
1021
909
|
*/
|
|
1022
|
-
getProtocols() {
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
910
|
+
async getProtocols({ block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
911
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_PROTOCOLS, [
|
|
912
|
+
block,
|
|
913
|
+
]);
|
|
914
|
+
if (this.has(key)) {
|
|
915
|
+
return this.get(key);
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
const response = this.rpcClient.getProtocols({ block });
|
|
919
|
+
this.put(key, response);
|
|
920
|
+
return response;
|
|
921
|
+
}
|
|
1036
922
|
}
|
|
1037
923
|
/**
|
|
1038
|
-
* @param
|
|
1039
|
-
*
|
|
924
|
+
* @param protocol the protocol hash to look up (default to empty string)
|
|
925
|
+
* get current and next protocol
|
|
1040
926
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-protocols
|
|
1041
927
|
*/
|
|
1042
|
-
getProtocolActivations() {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
throw new utils_1.InvalidProtocolHashError(protocol, protocolValidation);
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_PROTOCOL_ACTIVATIONS, [protocol]);
|
|
1051
|
-
if (this.has(key)) {
|
|
1052
|
-
return this.get(key);
|
|
1053
|
-
}
|
|
1054
|
-
else {
|
|
1055
|
-
const response = this.rpcClient.getProtocolActivations(protocol);
|
|
1056
|
-
this.put(key, response);
|
|
1057
|
-
return response;
|
|
928
|
+
async getProtocolActivations(protocol = '') {
|
|
929
|
+
if (protocol) {
|
|
930
|
+
const protocolValidation = (0, utils_1.validateProtocol)(protocol);
|
|
931
|
+
if (protocolValidation !== utils_1.ValidationResult.VALID) {
|
|
932
|
+
throw new utils_1.InvalidProtocolHashError(protocol, protocolValidation);
|
|
1058
933
|
}
|
|
1059
|
-
}
|
|
934
|
+
}
|
|
935
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_PROTOCOL_ACTIVATIONS, [protocol]);
|
|
936
|
+
if (this.has(key)) {
|
|
937
|
+
return this.get(key);
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
const response = this.rpcClient.getProtocolActivations(protocol);
|
|
941
|
+
this.put(key, response);
|
|
942
|
+
return response;
|
|
943
|
+
}
|
|
1060
944
|
}
|
|
1061
945
|
/**
|
|
1062
946
|
* @param contract address of the contract we want to retrieve storage information of
|
|
1063
947
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1064
|
-
*
|
|
948
|
+
* Access the used storage space of the contract
|
|
1065
949
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1066
950
|
*/
|
|
1067
|
-
getStorageUsedSpace(
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
}
|
|
1078
|
-
});
|
|
951
|
+
async getStorageUsedSpace(contract, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
952
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_STORAGE_USED_SPACE, [block, contract]);
|
|
953
|
+
if (this.has(key)) {
|
|
954
|
+
return this.get(key);
|
|
955
|
+
}
|
|
956
|
+
else {
|
|
957
|
+
const response = this.rpcClient.getStorageUsedSpace(contract, { block });
|
|
958
|
+
this.put(key, response);
|
|
959
|
+
return response;
|
|
960
|
+
}
|
|
1079
961
|
}
|
|
1080
962
|
/**
|
|
1081
963
|
* @param contract address of the contract we want to retrieve storage information of
|
|
1082
964
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1083
|
-
= *
|
|
965
|
+
= * Access the paid storage space of the contract
|
|
1084
966
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1085
967
|
*/
|
|
1086
|
-
getStoragePaidSpace(
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
968
|
+
async getStoragePaidSpace(contract, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
969
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_STORAGE_PAID_SPACE, [block, contract]);
|
|
970
|
+
if (this.has(key)) {
|
|
971
|
+
return this.get(key);
|
|
972
|
+
}
|
|
973
|
+
else {
|
|
974
|
+
const response = this.rpcClient.getStoragePaidSpace(contract, { block });
|
|
975
|
+
this.put(key, response);
|
|
976
|
+
return response;
|
|
977
|
+
}
|
|
1098
978
|
}
|
|
1099
979
|
/**
|
|
1100
980
|
* @param contract implicit or originated address we want to retrieve ticket balance of
|
|
1101
981
|
* @param ticket object to specify a ticket by ticketer, content type and content
|
|
1102
982
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1103
|
-
*
|
|
983
|
+
* Access the contract's balance of ticket with specified ticketer, content type, and content.
|
|
1104
984
|
* @example ticket { ticketer: 'address', content_type: { prim: "string" }, content: { string: 'ticket1' } }
|
|
1105
985
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1106
986
|
*/
|
|
1107
|
-
getTicketBalance(
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
987
|
+
async getTicketBalance(contract, ticket, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
988
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_TICKET_BALANCE, [block, contract], ticket);
|
|
989
|
+
if (this.has(key)) {
|
|
990
|
+
return this.get(key);
|
|
991
|
+
}
|
|
992
|
+
else {
|
|
993
|
+
const response = this.rpcClient.getTicketBalance(contract, ticket, { block });
|
|
994
|
+
this.put(key, response);
|
|
995
|
+
return response;
|
|
996
|
+
}
|
|
1119
997
|
}
|
|
1120
998
|
/**
|
|
1121
999
|
* @param contract originated address we want to retrieve ticket balances of
|
|
1122
1000
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1123
|
-
*
|
|
1001
|
+
* Access the complete list of tickets owned by the given contract by scanning the contract's storage.
|
|
1124
1002
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
1125
1003
|
*/
|
|
1126
|
-
getAllTicketBalances(
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1004
|
+
async getAllTicketBalances(contract, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
1005
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_ALL_TICKET_BALANCES, [block, contract]);
|
|
1006
|
+
if (this.has(key)) {
|
|
1007
|
+
return this.get(key);
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
const response = this.rpcClient.getAllTicketBalances(contract, { block });
|
|
1011
|
+
this.put(key, response);
|
|
1012
|
+
return response;
|
|
1013
|
+
}
|
|
1138
1014
|
}
|
|
1139
1015
|
/**
|
|
1140
|
-
*
|
|
1016
|
+
* 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.
|
|
1141
1017
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1142
1018
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-adaptive-issuance-launch-cycle
|
|
1143
1019
|
*/
|
|
1144
|
-
getAdaptiveIssuanceLaunchCycle() {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1020
|
+
async getAdaptiveIssuanceLaunchCycle({ block, } = rpc_client_interface_2.defaultRPCOptions) {
|
|
1021
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_ADAPTIVE_ISSUANCE_LAUNCH_CYCLE, [block]);
|
|
1022
|
+
if (this.has(key)) {
|
|
1023
|
+
return this.get(key);
|
|
1024
|
+
}
|
|
1025
|
+
else {
|
|
1026
|
+
const response = this.rpcClient.getAdaptiveIssuanceLaunchCycle({ block });
|
|
1027
|
+
this.put(key, response);
|
|
1028
|
+
return response;
|
|
1029
|
+
}
|
|
1156
1030
|
}
|
|
1157
1031
|
/**
|
|
1158
|
-
*
|
|
1032
|
+
* List the prevalidated operations in mempool (accessibility of mempool depends on each rpc endpoint)
|
|
1159
1033
|
* @param args has 5 optional properties
|
|
1160
1034
|
* @default args { version: '2', validated: true, refused: true, outdated, true, branchRefused: true, branchDelayed: true, validationPass: undefined }
|
|
1161
1035
|
*/
|
|
1162
|
-
getPendingOperations() {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1036
|
+
async getPendingOperations(args = {}) {
|
|
1037
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_PENDING_OPERATIONS, [args]);
|
|
1038
|
+
if (this.has(key)) {
|
|
1039
|
+
return this.get(key);
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
const response = this.rpcClient.getPendingOperations(args);
|
|
1043
|
+
this.put(key, response);
|
|
1044
|
+
return response;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Returns the current mempool fee filter configuration.
|
|
1049
|
+
* @param args optional query arguments for the mempool/filter endpoint
|
|
1050
|
+
*/
|
|
1051
|
+
async getMempoolFilter(args = {}) {
|
|
1052
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_MEMPOOL_FILTER, [
|
|
1053
|
+
args,
|
|
1054
|
+
]);
|
|
1055
|
+
if (this.has(key)) {
|
|
1056
|
+
return this.get(key);
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
const response = this.rpcClient.getMempoolFilter(args);
|
|
1060
|
+
this.put(key, response);
|
|
1061
|
+
return response;
|
|
1062
|
+
}
|
|
1174
1063
|
}
|
|
1175
1064
|
/**
|
|
1176
1065
|
* @param delegate delegate address which we want to retrieve active staking parameters
|
|
1177
1066
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1178
|
-
*
|
|
1067
|
+
* Returns the currently active staking parameters for the given delegate
|
|
1179
1068
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-active-staking-parameters
|
|
1180
1069
|
*/
|
|
1181
|
-
getActiveStakingParameters(
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
}
|
|
1193
|
-
});
|
|
1070
|
+
async getActiveStakingParameters(delegate, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
1071
|
+
this.validateAddress(delegate);
|
|
1072
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_ACTIVE_STAKING_PARAMETERS, [block, delegate]);
|
|
1073
|
+
if (this.has(key)) {
|
|
1074
|
+
return this.get(key);
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
const response = this.rpcClient.getActiveStakingParameters(delegate, { block });
|
|
1078
|
+
this.put(key, response);
|
|
1079
|
+
return response;
|
|
1080
|
+
}
|
|
1194
1081
|
}
|
|
1195
1082
|
/**
|
|
1196
1083
|
* @param delegate delegate address which we want to retrieve pending staking parameters
|
|
1197
1084
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1198
|
-
*
|
|
1085
|
+
* Returns the pending values for the given delegate's staking parameters
|
|
1199
1086
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-pending-staking-parameters
|
|
1200
1087
|
*/
|
|
1201
|
-
getPendingStakingParameters(
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
}
|
|
1213
|
-
});
|
|
1088
|
+
async getPendingStakingParameters(delegate, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
1089
|
+
this.validateAddress(delegate);
|
|
1090
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_PENDING_STAKING_PARAMETERS, [block, delegate]);
|
|
1091
|
+
if (this.has(key)) {
|
|
1092
|
+
return this.get(key);
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
const response = this.rpcClient.getPendingStakingParameters(delegate, { block });
|
|
1096
|
+
this.put(key, response);
|
|
1097
|
+
return response;
|
|
1098
|
+
}
|
|
1214
1099
|
}
|
|
1215
1100
|
/**
|
|
1216
1101
|
* @param destination address to retrieve the index for
|
|
1217
1102
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1218
|
-
*
|
|
1103
|
+
* Returns the index assigned to the address if it was indexed by the opcode INDEX_ADDRESS, otherwise returns null
|
|
1219
1104
|
* @see https://octez.tezos.com/docs/alpha/rpc.html#get-block-id-context-destination-destination-id-index
|
|
1220
1105
|
*/
|
|
1221
|
-
getDestinationIndex(
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
}
|
|
1232
|
-
});
|
|
1106
|
+
async getDestinationIndex(destination, { block } = rpc_client_interface_2.defaultRPCOptions) {
|
|
1107
|
+
const key = this.formatCacheKey(this.rpcClient.getRpcUrl(), rpc_client_interface_1.RPCMethodName.GET_DESTINATION_INDEX, [block, destination]);
|
|
1108
|
+
if (this.has(key)) {
|
|
1109
|
+
return this.get(key);
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
const response = this.rpcClient.getDestinationIndex(destination, { block });
|
|
1113
|
+
this.put(key, response);
|
|
1114
|
+
return response;
|
|
1115
|
+
}
|
|
1233
1116
|
}
|
|
1234
1117
|
}
|
|
1235
1118
|
exports.RpcClientCache = RpcClientCache;
|