@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/lib/taquito-rpc.js
CHANGED
|
@@ -13,26 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
17
|
exports.RpcClient = exports.VERSION = exports.OpKind = exports.RpcClientCache = exports.defaultRPCOptions = exports.defaultChain = exports.castToBigNumber = void 0;
|
|
38
18
|
/**
|
|
@@ -58,7 +38,7 @@ Object.defineProperty(exports, "OpKind", { enumerable: true, get: function () {
|
|
|
58
38
|
var version_1 = require("./version");
|
|
59
39
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
|
60
40
|
/***
|
|
61
|
-
*
|
|
41
|
+
* RpcClient allows interaction with Tezos network through an rpc node
|
|
62
42
|
*/
|
|
63
43
|
class RpcClient {
|
|
64
44
|
/**
|
|
@@ -99,743 +79,681 @@ class RpcClient {
|
|
|
99
79
|
}
|
|
100
80
|
/**
|
|
101
81
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
102
|
-
*
|
|
82
|
+
* Get the block's hash, its unique identifier.
|
|
103
83
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-hash
|
|
104
84
|
*/
|
|
105
|
-
getBlockHash() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
method: 'GET',
|
|
110
|
-
});
|
|
111
|
-
return hash;
|
|
85
|
+
async getBlockHash({ block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
86
|
+
const hash = await this.httpBackend.createRequest({
|
|
87
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/hash`),
|
|
88
|
+
method: 'GET',
|
|
112
89
|
});
|
|
90
|
+
return hash;
|
|
113
91
|
}
|
|
114
92
|
/**
|
|
115
93
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
116
|
-
*
|
|
94
|
+
* 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.
|
|
117
95
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-live-blocks
|
|
118
96
|
*/
|
|
119
|
-
getLiveBlocks() {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
method: 'GET',
|
|
124
|
-
});
|
|
125
|
-
return blocks;
|
|
97
|
+
async getLiveBlocks({ block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
98
|
+
const blocks = await this.httpBackend.createRequest({
|
|
99
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/live_blocks`),
|
|
100
|
+
method: 'GET',
|
|
126
101
|
});
|
|
102
|
+
return blocks;
|
|
127
103
|
}
|
|
128
104
|
/**
|
|
129
105
|
* @param address address from which we want to retrieve the spendable balance
|
|
130
106
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
131
|
-
*
|
|
107
|
+
* 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.
|
|
132
108
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-balance
|
|
133
109
|
*/
|
|
134
|
-
getBalance(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
method: 'GET',
|
|
140
|
-
});
|
|
141
|
-
return new bignumber_js_1.default(balance);
|
|
110
|
+
async getBalance(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
111
|
+
this.validateAddress(address);
|
|
112
|
+
const balance = await this.httpBackend.createRequest({
|
|
113
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/balance`),
|
|
114
|
+
method: 'GET',
|
|
142
115
|
});
|
|
116
|
+
return new bignumber_js_1.default(balance);
|
|
143
117
|
}
|
|
144
118
|
/**
|
|
145
119
|
* @param address address from which we want to retrieve the spendable balance
|
|
146
120
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
147
|
-
*
|
|
121
|
+
* 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.
|
|
148
122
|
*/
|
|
149
|
-
getSpendable(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
method: 'GET',
|
|
155
|
-
});
|
|
156
|
-
return new bignumber_js_1.default(balance);
|
|
123
|
+
async getSpendable(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
124
|
+
this.validateAddress(address);
|
|
125
|
+
const balance = await this.httpBackend.createRequest({
|
|
126
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/spendable`),
|
|
127
|
+
method: 'GET',
|
|
157
128
|
});
|
|
129
|
+
return new bignumber_js_1.default(balance);
|
|
158
130
|
}
|
|
159
131
|
/**
|
|
160
132
|
* @param address address from which we want to retrieve balance and frozen bonds
|
|
161
133
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
162
|
-
*
|
|
134
|
+
* 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.
|
|
163
135
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-full-balance
|
|
164
136
|
*/
|
|
165
|
-
getBalanceAndFrozenBonds(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
method: 'GET',
|
|
171
|
-
});
|
|
172
|
-
return new bignumber_js_1.default(balance);
|
|
137
|
+
async getBalanceAndFrozenBonds(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
138
|
+
this.validateAddress(address);
|
|
139
|
+
const balance = await this.httpBackend.createRequest({
|
|
140
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/balance_and_frozen_bonds`),
|
|
141
|
+
method: 'GET',
|
|
173
142
|
});
|
|
143
|
+
return new bignumber_js_1.default(balance);
|
|
174
144
|
}
|
|
175
145
|
/**
|
|
176
146
|
* @param address address from which we want to retrieve spendable and frozen bonds
|
|
177
147
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
178
|
-
*
|
|
148
|
+
* 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.
|
|
179
149
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-full-balance
|
|
180
150
|
*/
|
|
181
|
-
getSpendableAndFrozenBonds(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
method: 'GET',
|
|
187
|
-
});
|
|
188
|
-
return new bignumber_js_1.default(balance);
|
|
151
|
+
async getSpendableAndFrozenBonds(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
152
|
+
this.validateAddress(address);
|
|
153
|
+
const balance = await this.httpBackend.createRequest({
|
|
154
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/spendable_and_frozen_bonds`),
|
|
155
|
+
method: 'GET',
|
|
189
156
|
});
|
|
157
|
+
return new bignumber_js_1.default(balance);
|
|
190
158
|
}
|
|
191
159
|
/**
|
|
192
160
|
* @param address address from which we want to retrieve the full balance
|
|
193
161
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
194
|
-
*
|
|
162
|
+
* Access the full balance of a contract, including frozen bonds and stake.
|
|
195
163
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-full-balance
|
|
196
164
|
*/
|
|
197
|
-
getFullBalance(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
method: 'GET',
|
|
203
|
-
});
|
|
204
|
-
return new bignumber_js_1.default(balance);
|
|
165
|
+
async getFullBalance(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
166
|
+
this.validateAddress(address);
|
|
167
|
+
const balance = await this.httpBackend.createRequest({
|
|
168
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/full_balance`),
|
|
169
|
+
method: 'GET',
|
|
205
170
|
});
|
|
171
|
+
return new bignumber_js_1.default(balance);
|
|
206
172
|
}
|
|
207
173
|
/**
|
|
208
174
|
* @param address address from which we want to retrieve the staked balance
|
|
209
175
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
210
|
-
*
|
|
176
|
+
* Access the staked balance of a contract. Returns None if the contract is originated, or neither delegated nor a delegate.
|
|
211
177
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-staked-balance
|
|
212
178
|
*/
|
|
213
|
-
getStakedBalance(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
method: 'GET',
|
|
219
|
-
});
|
|
220
|
-
return new bignumber_js_1.default(balance);
|
|
179
|
+
async getStakedBalance(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
180
|
+
this.validateAddress(address);
|
|
181
|
+
const balance = await this.httpBackend.createRequest({
|
|
182
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/staked_balance`),
|
|
183
|
+
method: 'GET',
|
|
221
184
|
});
|
|
185
|
+
return new bignumber_js_1.default(balance);
|
|
222
186
|
}
|
|
223
187
|
/**
|
|
224
188
|
* @param address address from which we want to retrieve the unstaked finalizable balance
|
|
225
189
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
226
|
-
*
|
|
190
|
+
* 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.
|
|
227
191
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstaked-finalizable-balance
|
|
228
192
|
*/
|
|
229
|
-
getUnstakedFinalizableBalance(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
method: 'GET',
|
|
235
|
-
});
|
|
236
|
-
return new bignumber_js_1.default(balance);
|
|
193
|
+
async getUnstakedFinalizableBalance(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
194
|
+
this.validateAddress(address);
|
|
195
|
+
const balance = await this.httpBackend.createRequest({
|
|
196
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/unstaked_finalizable_balance`),
|
|
197
|
+
method: 'GET',
|
|
237
198
|
});
|
|
199
|
+
return new bignumber_js_1.default(balance);
|
|
238
200
|
}
|
|
239
201
|
/**
|
|
240
202
|
* @param address address from which we want to retrieve the unstaked frozen balance
|
|
241
203
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
242
|
-
*
|
|
204
|
+
* 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.
|
|
243
205
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstaked-frozen-balance
|
|
244
206
|
*/
|
|
245
|
-
getUnstakedFrozenBalance(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
method: 'GET',
|
|
251
|
-
});
|
|
252
|
-
return new bignumber_js_1.default(balance);
|
|
207
|
+
async getUnstakedFrozenBalance(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
208
|
+
this.validateAddress(address);
|
|
209
|
+
const balance = await this.httpBackend.createRequest({
|
|
210
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/unstaked_frozen_balance`),
|
|
211
|
+
method: 'GET',
|
|
253
212
|
});
|
|
213
|
+
return new bignumber_js_1.default(balance);
|
|
254
214
|
}
|
|
255
215
|
/**
|
|
256
216
|
* @param address address from which we want to retrieve the unstaked requests
|
|
257
217
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
258
|
-
*
|
|
218
|
+
* 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.
|
|
259
219
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-unstake-requests
|
|
260
220
|
*/
|
|
261
|
-
getUnstakeRequests(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
: {
|
|
271
|
-
|
|
272
|
-
|
|
221
|
+
async getUnstakeRequests(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
222
|
+
this.validateAddress(address);
|
|
223
|
+
const response = await this.httpBackend.createRequest({
|
|
224
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/unstake_requests`),
|
|
225
|
+
method: 'GET',
|
|
226
|
+
});
|
|
227
|
+
return response === null
|
|
228
|
+
? null
|
|
229
|
+
: {
|
|
230
|
+
finalizable: response.finalizable.map(({ amount, ...rest }) => {
|
|
231
|
+
const castedToBigNumber = (0, utils_1.castToBigNumber)({ amount }, ['amount']);
|
|
232
|
+
return {
|
|
233
|
+
...rest,
|
|
234
|
+
amount: castedToBigNumber.amount,
|
|
235
|
+
};
|
|
236
|
+
}),
|
|
237
|
+
unfinalizable: {
|
|
238
|
+
delegate: response.unfinalizable.delegate,
|
|
239
|
+
requests: response.unfinalizable.requests.map(({ amount, cycle }) => {
|
|
273
240
|
const castedToBigNumber = (0, utils_1.castToBigNumber)({ amount }, ['amount']);
|
|
274
|
-
return
|
|
241
|
+
return {
|
|
242
|
+
cycle,
|
|
243
|
+
amount: castedToBigNumber.amount,
|
|
244
|
+
};
|
|
275
245
|
}),
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
requests: response.unfinalizable.requests.map(({ amount, cycle }) => {
|
|
279
|
-
const castedToBigNumber = (0, utils_1.castToBigNumber)({ amount }, ['amount']);
|
|
280
|
-
return {
|
|
281
|
-
cycle,
|
|
282
|
-
amount: castedToBigNumber.amount,
|
|
283
|
-
};
|
|
284
|
-
}),
|
|
285
|
-
},
|
|
286
|
-
};
|
|
287
|
-
});
|
|
246
|
+
},
|
|
247
|
+
};
|
|
288
248
|
}
|
|
289
249
|
/**
|
|
290
250
|
* @param address contract address from which we want to retrieve the storage
|
|
291
251
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
292
|
-
*
|
|
252
|
+
* Access the data of the contract.
|
|
293
253
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-storage
|
|
294
254
|
*/
|
|
295
|
-
getStorage(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
method: 'GET',
|
|
301
|
-
});
|
|
255
|
+
async getStorage(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
256
|
+
this.validateContract(address);
|
|
257
|
+
return this.httpBackend.createRequest({
|
|
258
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/storage`),
|
|
259
|
+
method: 'GET',
|
|
302
260
|
});
|
|
303
261
|
}
|
|
304
262
|
/**
|
|
305
263
|
* @param address contract address from which we want to retrieve the script
|
|
306
264
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
307
|
-
*
|
|
265
|
+
* Access the code and data of the contract.
|
|
308
266
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-script
|
|
309
267
|
*/
|
|
310
|
-
getScript(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
method: 'GET',
|
|
316
|
-
});
|
|
268
|
+
async getScript(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
269
|
+
this.validateContract(address);
|
|
270
|
+
return this.httpBackend.createRequest({
|
|
271
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/script`),
|
|
272
|
+
method: 'GET',
|
|
317
273
|
});
|
|
318
274
|
}
|
|
319
275
|
/**
|
|
320
276
|
* @param address contract address from which we want to retrieve the script
|
|
321
277
|
* @param unparsingMode default is { unparsing_mode: "Readable" }
|
|
322
278
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
323
|
-
*
|
|
279
|
+
* Access the script of the contract and normalize it using the requested unparsing mode.
|
|
324
280
|
*/
|
|
325
|
-
getNormalizedScript(
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}, unparsingMode);
|
|
332
|
-
});
|
|
281
|
+
async getNormalizedScript(address, unparsingMode = { unparsing_mode: 'Readable' }, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
282
|
+
this.validateContract(address);
|
|
283
|
+
return this.httpBackend.createRequest({
|
|
284
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/script/normalized`),
|
|
285
|
+
method: 'POST',
|
|
286
|
+
}, unparsingMode);
|
|
333
287
|
}
|
|
334
288
|
/**
|
|
335
289
|
* @param address contract address from which we want to retrieve
|
|
336
290
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
337
|
-
*
|
|
291
|
+
* Access the complete status of a contract.
|
|
338
292
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id
|
|
339
293
|
*/
|
|
340
|
-
getContract(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
method: 'GET',
|
|
346
|
-
});
|
|
347
|
-
return Object.assign(Object.assign({}, contractResponse), { balance: new bignumber_js_1.default(contractResponse.balance) });
|
|
294
|
+
async getContract(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
295
|
+
this.validateAddress(address);
|
|
296
|
+
const contractResponse = await this.httpBackend.createRequest({
|
|
297
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}`),
|
|
298
|
+
method: 'GET',
|
|
348
299
|
});
|
|
300
|
+
return {
|
|
301
|
+
...contractResponse,
|
|
302
|
+
balance: new bignumber_js_1.default(contractResponse.balance),
|
|
303
|
+
};
|
|
349
304
|
}
|
|
350
305
|
/**
|
|
351
306
|
* @param address contract address from which we want to retrieve the manager
|
|
352
307
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
353
|
-
*
|
|
308
|
+
* Access the manager of an implicit contract
|
|
354
309
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-manager-key
|
|
355
310
|
*/
|
|
356
|
-
getManagerKey(
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
method: 'GET',
|
|
362
|
-
});
|
|
311
|
+
async getManagerKey(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
312
|
+
this.validateAddress(address);
|
|
313
|
+
return this.httpBackend.createRequest({
|
|
314
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/manager_key`),
|
|
315
|
+
method: 'GET',
|
|
363
316
|
});
|
|
364
317
|
}
|
|
365
318
|
/**
|
|
366
319
|
* @param address contract address from which we want to retrieve the delegate (baker)
|
|
367
320
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
368
|
-
*
|
|
321
|
+
* Access the delegate of a contract, if any
|
|
369
322
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-delegate
|
|
370
323
|
*/
|
|
371
|
-
getDelegate(
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
324
|
+
async getDelegate(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
325
|
+
this.validateAddress(address);
|
|
326
|
+
let delegate;
|
|
327
|
+
try {
|
|
328
|
+
delegate = await this.httpBackend.createRequest({
|
|
329
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${address}/delegate`),
|
|
330
|
+
method: 'GET',
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
catch (ex) {
|
|
334
|
+
if (ex instanceof http_utils_1.HttpResponseError && ex.status === http_utils_1.STATUS_CODE.NOT_FOUND) {
|
|
335
|
+
delegate = null;
|
|
380
336
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
delegate = null;
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
throw ex;
|
|
387
|
-
}
|
|
337
|
+
else {
|
|
338
|
+
throw ex;
|
|
388
339
|
}
|
|
389
|
-
|
|
390
|
-
|
|
340
|
+
}
|
|
341
|
+
return delegate;
|
|
391
342
|
}
|
|
392
343
|
/**
|
|
393
344
|
* @param id Big Map ID
|
|
394
345
|
* @param expr Expression hash to query (A b58check encoded Blake2b hash of the expression (The expression can be packed using the pack_data method))
|
|
395
346
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
396
|
-
*
|
|
347
|
+
* Access the value associated with a key in a big map.
|
|
397
348
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-big-maps-big-map-id-script-expr
|
|
398
349
|
*/
|
|
399
|
-
getBigMapExpr(
|
|
400
|
-
return
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
method: 'GET',
|
|
404
|
-
});
|
|
350
|
+
async getBigMapExpr(id, expr, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
351
|
+
return this.httpBackend.createRequest({
|
|
352
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/big_maps/${id}/${expr}`),
|
|
353
|
+
method: 'GET',
|
|
405
354
|
});
|
|
406
355
|
}
|
|
407
356
|
/**
|
|
408
357
|
* @param args contains optional query arguments (active, inactive, with_minimal_stake, without_minimal_stake)
|
|
409
358
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
410
|
-
*
|
|
359
|
+
* Lists all registered delegates by default with query arguments to filter unneeded values.
|
|
411
360
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh
|
|
412
361
|
*/
|
|
413
|
-
getAllDelegates() {
|
|
414
|
-
return
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
query: args,
|
|
419
|
-
});
|
|
362
|
+
async getAllDelegates(args = {}, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
363
|
+
return await this.httpBackend.createRequest({
|
|
364
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates`),
|
|
365
|
+
method: 'GET',
|
|
366
|
+
query: args,
|
|
420
367
|
});
|
|
421
368
|
}
|
|
422
369
|
/**
|
|
423
370
|
* @param address delegate address which we want to retrieve
|
|
424
371
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
425
|
-
*
|
|
372
|
+
* Everything about a delegate
|
|
426
373
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh
|
|
427
374
|
*/
|
|
428
|
-
getDelegates(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
375
|
+
async getDelegates(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
376
|
+
this.validateAddress(address);
|
|
377
|
+
const response = await this.httpBackend.createRequest({
|
|
378
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates/${address}`),
|
|
379
|
+
method: 'GET',
|
|
380
|
+
});
|
|
381
|
+
const castedResponse = (0, utils_1.castToBigNumber)(response, [
|
|
382
|
+
'balance',
|
|
383
|
+
'full_balance',
|
|
384
|
+
'current_frozen_deposits',
|
|
385
|
+
'frozen_deposits',
|
|
386
|
+
'frozen_balance',
|
|
387
|
+
'frozen_deposits_limit',
|
|
388
|
+
'staking_balance',
|
|
389
|
+
'delegated_balance',
|
|
390
|
+
'voting_power',
|
|
391
|
+
'total_delegated_stake',
|
|
392
|
+
'staking_denominator',
|
|
393
|
+
]);
|
|
394
|
+
if (response.frozen_balance_by_cycle) {
|
|
395
|
+
return {
|
|
396
|
+
...response,
|
|
397
|
+
...castedResponse,
|
|
398
|
+
frozen_balance_by_cycle: response.frozen_balance_by_cycle.map(({ deposit, deposits, fees, rewards, ...rest }) => {
|
|
399
|
+
const castedToBigNumber = (0, utils_1.castToBigNumber)({ deposit, deposits, fees, rewards }, [
|
|
400
|
+
'deposit',
|
|
401
|
+
'deposits',
|
|
402
|
+
'fees',
|
|
403
|
+
'rewards',
|
|
404
|
+
]);
|
|
405
|
+
return {
|
|
406
|
+
...rest,
|
|
407
|
+
deposit: castedToBigNumber.deposit,
|
|
408
|
+
deposits: castedToBigNumber.deposits,
|
|
409
|
+
fees: castedToBigNumber.fees,
|
|
410
|
+
rewards: castedToBigNumber.rewards,
|
|
411
|
+
};
|
|
412
|
+
}),
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
return {
|
|
417
|
+
...response,
|
|
418
|
+
...castedResponse,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
464
421
|
}
|
|
465
422
|
/**
|
|
466
423
|
* @param address delegate address which we want to retrieve
|
|
467
424
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
468
|
-
*
|
|
425
|
+
* Returns the delegate info (e.g. voting power) found in the listings of the current voting period
|
|
469
426
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-voting-info
|
|
470
427
|
*/
|
|
471
|
-
getVotingInfo(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
method: 'GET',
|
|
477
|
-
});
|
|
428
|
+
async getVotingInfo(address, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
429
|
+
this.validateAddress(address);
|
|
430
|
+
return await this.httpBackend.createRequest({
|
|
431
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates/${address}/voting_info`),
|
|
432
|
+
method: 'GET',
|
|
478
433
|
});
|
|
479
434
|
}
|
|
480
435
|
/**
|
|
481
436
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
482
|
-
*
|
|
437
|
+
* All constants
|
|
483
438
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-constants
|
|
484
439
|
*/
|
|
485
|
-
getConstants() {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
440
|
+
async getConstants({ block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
441
|
+
const response = await this.httpBackend.createRequest({
|
|
442
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/constants`),
|
|
443
|
+
method: 'GET',
|
|
444
|
+
});
|
|
445
|
+
const castedResponse = (0, utils_1.castToBigNumber)(response, [
|
|
446
|
+
'time_between_blocks',
|
|
447
|
+
'hard_gas_limit_per_operation',
|
|
448
|
+
'hard_gas_limit_per_block',
|
|
449
|
+
'proof_of_work_threshold',
|
|
450
|
+
'tokens_per_roll',
|
|
451
|
+
'seed_nonce_revelation_tip',
|
|
452
|
+
'block_security_deposit',
|
|
453
|
+
'endorsement_security_deposit',
|
|
454
|
+
'block_reward',
|
|
455
|
+
'endorsement_reward',
|
|
456
|
+
'cost_per_byte',
|
|
457
|
+
'hard_storage_limit_per_operation',
|
|
458
|
+
'test_chain_duration',
|
|
459
|
+
'baking_reward_per_endorsement',
|
|
460
|
+
'delay_per_missing_endorsement',
|
|
461
|
+
'minimal_block_delay',
|
|
462
|
+
'liquidity_baking_subsidy',
|
|
463
|
+
'cache_layout',
|
|
464
|
+
'baking_reward_fixed_portion',
|
|
465
|
+
'baking_reward_bonus_per_slot',
|
|
466
|
+
'endorsing_reward_per_slot',
|
|
467
|
+
'double_baking_punishment',
|
|
468
|
+
'delay_increment_per_round',
|
|
469
|
+
'tx_rollup_commitment_bond',
|
|
470
|
+
'vdf_difficulty',
|
|
471
|
+
'sc_rollup_stake_amount',
|
|
472
|
+
'minimal_stake',
|
|
473
|
+
]);
|
|
474
|
+
return {
|
|
475
|
+
...response,
|
|
476
|
+
...castedResponse,
|
|
477
|
+
};
|
|
522
478
|
}
|
|
523
479
|
/**
|
|
524
480
|
* @param options contains generic configuration for rpc calls to specified block (default to head) and version.
|
|
525
|
-
*
|
|
481
|
+
* All the information about a block
|
|
526
482
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id
|
|
527
483
|
* @example getBlock() will default to `/main/chains/block/head?version=1`
|
|
528
484
|
* @example getBlock({ block: 'head~2' }) will return an offset of 2 from head blocks
|
|
529
485
|
* @example getBlock({ block: 'BL8fTiWcSxWCjiMVnDkbh6EuhqVPZzgWheJ2dqwrxYRm9AephXh~2' }) will return an offset of 2 blocks from given block hash..
|
|
530
486
|
*/
|
|
531
|
-
getBlock() {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
return yield this.httpBackend.createRequest(requestOptions);
|
|
541
|
-
});
|
|
487
|
+
async getBlock({ block, version } = rpc_client_interface_1.defaultRPCOptions) {
|
|
488
|
+
const requestOptions = {
|
|
489
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}`),
|
|
490
|
+
method: 'GET',
|
|
491
|
+
};
|
|
492
|
+
if (version !== undefined) {
|
|
493
|
+
requestOptions.query = { version };
|
|
494
|
+
}
|
|
495
|
+
return await this.httpBackend.createRequest(requestOptions);
|
|
542
496
|
}
|
|
543
497
|
/**
|
|
544
498
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
545
|
-
*
|
|
499
|
+
* The whole block header
|
|
546
500
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-header
|
|
547
501
|
*/
|
|
548
|
-
getBlockHeader() {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
method: 'GET',
|
|
553
|
-
});
|
|
554
|
-
return response;
|
|
502
|
+
async getBlockHeader({ block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
503
|
+
const response = await this.httpBackend.createRequest({
|
|
504
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/header`),
|
|
505
|
+
method: 'GET',
|
|
555
506
|
});
|
|
507
|
+
return response;
|
|
556
508
|
}
|
|
557
509
|
/**
|
|
558
510
|
* @param options contains generic configuration for rpc calls to specified block (default to head) and version
|
|
559
|
-
*
|
|
511
|
+
* All the metadata associated to the block
|
|
560
512
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-metadata
|
|
561
513
|
*/
|
|
562
|
-
getBlockMetadata() {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
return yield this.httpBackend.createRequest(requestOptions);
|
|
572
|
-
});
|
|
514
|
+
async getBlockMetadata({ block, version, } = rpc_client_interface_1.defaultRPCOptions) {
|
|
515
|
+
const requestOptions = {
|
|
516
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/metadata`),
|
|
517
|
+
method: 'GET',
|
|
518
|
+
};
|
|
519
|
+
if (version !== undefined) {
|
|
520
|
+
requestOptions.query = { version };
|
|
521
|
+
}
|
|
522
|
+
return await this.httpBackend.createRequest(requestOptions);
|
|
573
523
|
}
|
|
574
524
|
/**
|
|
575
525
|
* @param args contains optional query arguments (level, cycle, delegate, consensus_key, and max_round)
|
|
576
526
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
577
|
-
*
|
|
527
|
+
* Retrieves the list of delegates allowed to bake a block.
|
|
578
528
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
579
529
|
*/
|
|
580
|
-
getBakingRights() {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
query: args,
|
|
586
|
-
});
|
|
587
|
-
return response;
|
|
530
|
+
async getBakingRights(args = {}, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
531
|
+
const response = await this.httpBackend.createRequest({
|
|
532
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/baking_rights`),
|
|
533
|
+
method: 'GET',
|
|
534
|
+
query: args,
|
|
588
535
|
});
|
|
536
|
+
return response;
|
|
589
537
|
}
|
|
590
538
|
/**
|
|
591
539
|
* @param args contains optional query arguments (level, cycle, delegate, and consensus_key)
|
|
592
540
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
593
|
-
*
|
|
541
|
+
* Retrieves the delegates allowed to attest a block
|
|
594
542
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
595
543
|
*/
|
|
596
|
-
getAttestationRights() {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
query: args,
|
|
602
|
-
});
|
|
603
|
-
return response;
|
|
544
|
+
async getAttestationRights(args = {}, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
545
|
+
const response = await this.httpBackend.createRequest({
|
|
546
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/attestation_rights`),
|
|
547
|
+
method: 'GET',
|
|
548
|
+
query: args,
|
|
604
549
|
});
|
|
550
|
+
return response;
|
|
605
551
|
}
|
|
606
552
|
/**
|
|
607
553
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
608
|
-
*
|
|
554
|
+
* Ballots casted so far during a voting period
|
|
609
555
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-ballot-list
|
|
610
556
|
*/
|
|
611
|
-
getBallotList() {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
method: 'GET',
|
|
616
|
-
});
|
|
617
|
-
return response;
|
|
557
|
+
async getBallotList({ block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
558
|
+
const response = await this.httpBackend.createRequest({
|
|
559
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/ballot_list`),
|
|
560
|
+
method: 'GET',
|
|
618
561
|
});
|
|
562
|
+
return response;
|
|
619
563
|
}
|
|
620
564
|
/**
|
|
621
565
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
622
|
-
*
|
|
566
|
+
* Sum of ballots casted so far during a voting period
|
|
623
567
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-ballots
|
|
624
568
|
*/
|
|
625
|
-
getBallots() {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
method: 'GET',
|
|
630
|
-
});
|
|
631
|
-
const casted = (0, utils_1.castToBigNumber)(response, ['yay', 'nay', 'pass']);
|
|
632
|
-
return casted;
|
|
569
|
+
async getBallots({ block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
570
|
+
const response = await this.httpBackend.createRequest({
|
|
571
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/ballots`),
|
|
572
|
+
method: 'GET',
|
|
633
573
|
});
|
|
574
|
+
const casted = (0, utils_1.castToBigNumber)(response, ['yay', 'nay', 'pass']);
|
|
575
|
+
return casted;
|
|
634
576
|
}
|
|
635
577
|
/**
|
|
636
578
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
637
|
-
*
|
|
579
|
+
* Current proposal under evaluation.
|
|
638
580
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-proposal
|
|
639
581
|
*/
|
|
640
|
-
getCurrentProposal() {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
method: 'GET',
|
|
645
|
-
});
|
|
646
|
-
return response;
|
|
582
|
+
async getCurrentProposal({ block, } = rpc_client_interface_1.defaultRPCOptions) {
|
|
583
|
+
const response = await this.httpBackend.createRequest({
|
|
584
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/current_proposal`),
|
|
585
|
+
method: 'GET',
|
|
647
586
|
});
|
|
587
|
+
return response;
|
|
648
588
|
}
|
|
649
589
|
/**
|
|
650
590
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
651
|
-
*
|
|
591
|
+
* Current expected quorum.
|
|
652
592
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-quorum
|
|
653
593
|
*/
|
|
654
|
-
getCurrentQuorum() {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
method: 'GET',
|
|
659
|
-
});
|
|
660
|
-
return response;
|
|
594
|
+
async getCurrentQuorum({ block, } = rpc_client_interface_1.defaultRPCOptions) {
|
|
595
|
+
const response = await this.httpBackend.createRequest({
|
|
596
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/current_quorum`),
|
|
597
|
+
method: 'GET',
|
|
661
598
|
});
|
|
599
|
+
return response;
|
|
662
600
|
}
|
|
663
601
|
/**
|
|
664
602
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
665
|
-
*
|
|
603
|
+
* List of delegates with their voting power
|
|
666
604
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-listings
|
|
667
605
|
*/
|
|
668
|
-
getVotesListings() {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
return item;
|
|
679
|
-
});
|
|
680
|
-
return response;
|
|
606
|
+
async getVotesListings({ block, } = rpc_client_interface_1.defaultRPCOptions) {
|
|
607
|
+
const response = await this.httpBackend.createRequest({
|
|
608
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/listings`),
|
|
609
|
+
method: 'GET',
|
|
610
|
+
});
|
|
611
|
+
response.map((item) => {
|
|
612
|
+
if (item.voting_power) {
|
|
613
|
+
item.voting_power = new bignumber_js_1.default(item.voting_power);
|
|
614
|
+
}
|
|
615
|
+
return item;
|
|
681
616
|
});
|
|
617
|
+
return response;
|
|
682
618
|
}
|
|
683
619
|
/**
|
|
684
620
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
685
|
-
*
|
|
621
|
+
* List of proposals with number of supporters
|
|
686
622
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-proposals
|
|
687
623
|
*/
|
|
688
|
-
getProposals() {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
return (item[1] = new bignumber_js_1.default(item[1]));
|
|
696
|
-
});
|
|
697
|
-
return response;
|
|
624
|
+
async getProposals({ block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
625
|
+
const response = await this.httpBackend.createRequest({
|
|
626
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/proposals`),
|
|
627
|
+
method: 'GET',
|
|
628
|
+
});
|
|
629
|
+
response.map((item) => {
|
|
630
|
+
return (item[1] = new bignumber_js_1.default(item[1]));
|
|
698
631
|
});
|
|
632
|
+
return response;
|
|
699
633
|
}
|
|
700
634
|
/**
|
|
701
635
|
* @param data operation contents to forge
|
|
702
636
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
703
|
-
*
|
|
637
|
+
* Forge an operation returning the unsigned bytes
|
|
704
638
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
705
639
|
*/
|
|
706
|
-
forgeOperations(
|
|
707
|
-
return
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}, data);
|
|
712
|
-
});
|
|
640
|
+
async forgeOperations(data, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
641
|
+
return this.httpBackend.createRequest({
|
|
642
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/forge/operations`),
|
|
643
|
+
method: 'POST',
|
|
644
|
+
}, data);
|
|
713
645
|
}
|
|
714
646
|
/**
|
|
715
647
|
* @param signedOpBytes signed bytes to inject
|
|
716
|
-
*
|
|
648
|
+
* Inject an operation in node and broadcast it and return the ID of the operation
|
|
717
649
|
* @see https://tezos.gitlab.io/shell/rpc.html#post-injection-operation
|
|
718
650
|
*/
|
|
719
|
-
injectOperation(signedOpBytes) {
|
|
720
|
-
return
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}, signedOpBytes);
|
|
725
|
-
});
|
|
651
|
+
async injectOperation(signedOpBytes) {
|
|
652
|
+
return this.httpBackend.createRequest({
|
|
653
|
+
url: this.createURL(`/injection/operation`),
|
|
654
|
+
method: 'POST',
|
|
655
|
+
}, signedOpBytes);
|
|
726
656
|
}
|
|
727
657
|
/**
|
|
728
658
|
* @param ops Operations to apply
|
|
729
659
|
* @param options contains generic configuration for rpc calls to specified block and version
|
|
730
|
-
*
|
|
660
|
+
* Simulate the application of the operations with the context of the given block and return the result of each operation application
|
|
731
661
|
* @see https://tezos.gitlab.io/active/rpc.html#post-block-id-helpers-preapply-operations
|
|
732
662
|
*/
|
|
733
|
-
preapplyOperations(
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
return yield this.httpBackend.createRequest(requestOptions, ops);
|
|
743
|
-
});
|
|
663
|
+
async preapplyOperations(ops, { block, version } = rpc_client_interface_1.defaultRPCOptions) {
|
|
664
|
+
const requestOptions = {
|
|
665
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/preapply/operations`),
|
|
666
|
+
method: 'POST',
|
|
667
|
+
};
|
|
668
|
+
if (version !== undefined) {
|
|
669
|
+
requestOptions.query = { version };
|
|
670
|
+
}
|
|
671
|
+
return await this.httpBackend.createRequest(requestOptions, ops);
|
|
744
672
|
}
|
|
745
673
|
/**
|
|
746
674
|
* @param contract address of the contract we want to get the entrypoints of
|
|
747
675
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
748
|
-
*
|
|
676
|
+
* Return the list of entrypoints of the contract
|
|
749
677
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-entrypoints
|
|
750
|
-
* @version 005_PsBABY5H
|
|
678
|
+
* @remarks version 005_PsBABY5H
|
|
751
679
|
*/
|
|
752
|
-
getEntrypoints(
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
method: 'GET',
|
|
758
|
-
});
|
|
759
|
-
return contractResponse;
|
|
680
|
+
async getEntrypoints(contract, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
681
|
+
this.validateContract(contract);
|
|
682
|
+
const contractResponse = await this.httpBackend.createRequest({
|
|
683
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/entrypoints`),
|
|
684
|
+
method: 'GET',
|
|
760
685
|
});
|
|
686
|
+
return contractResponse;
|
|
761
687
|
}
|
|
762
688
|
/**
|
|
763
689
|
* @param op Operation to simulate
|
|
764
690
|
* @param options contains generic configuration for rpc calls to specified block and version
|
|
765
|
-
*
|
|
691
|
+
* 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.
|
|
766
692
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
767
693
|
*/
|
|
768
|
-
simulateOperation(
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
return yield this.httpBackend.createRequest(requestOptions, op);
|
|
778
|
-
});
|
|
694
|
+
async simulateOperation(op, { block, version } = rpc_client_interface_1.defaultRPCOptions) {
|
|
695
|
+
const requestOptions = {
|
|
696
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/simulate_operation`),
|
|
697
|
+
method: 'POST',
|
|
698
|
+
};
|
|
699
|
+
if (version !== undefined) {
|
|
700
|
+
requestOptions.query = { version };
|
|
701
|
+
}
|
|
702
|
+
return await this.httpBackend.createRequest(requestOptions, op);
|
|
779
703
|
}
|
|
780
704
|
/**
|
|
781
705
|
* @param code Code to run
|
|
782
706
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
783
|
-
*
|
|
707
|
+
* Run a Michelson script in the current context
|
|
784
708
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
785
709
|
*/
|
|
786
|
-
runCode(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return response;
|
|
793
|
-
});
|
|
710
|
+
async runCode(code, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
711
|
+
const response = await this.httpBackend.createRequest({
|
|
712
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/run_code`),
|
|
713
|
+
method: 'POST',
|
|
714
|
+
}, code);
|
|
715
|
+
return response;
|
|
794
716
|
}
|
|
795
717
|
/**
|
|
796
718
|
* @param viewScriptParams Parameters of the script view to run
|
|
797
719
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
798
|
-
*
|
|
720
|
+
* Simulate a call to a michelson view
|
|
799
721
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
800
722
|
*/
|
|
801
|
-
runScriptView(
|
|
802
|
-
return
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
}, Object.assign({ unparsing_mode }, rest));
|
|
723
|
+
async runScriptView({ unparsing_mode = 'Readable', ...rest }, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
724
|
+
return this.httpBackend.createRequest({
|
|
725
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/run_script_view`),
|
|
726
|
+
method: 'POST',
|
|
727
|
+
}, {
|
|
728
|
+
unparsing_mode,
|
|
729
|
+
...rest,
|
|
809
730
|
});
|
|
810
731
|
}
|
|
811
732
|
/**
|
|
812
733
|
* @param viewParams Parameters of the view to run
|
|
813
734
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
814
|
-
*
|
|
735
|
+
* Simulate a call to a view following the TZIP-4 standard.
|
|
815
736
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
816
737
|
*/
|
|
817
|
-
runView(
|
|
818
|
-
return
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
}, Object.assign({ unparsing_mode }, rest));
|
|
738
|
+
async runView({ unparsing_mode = 'Readable', ...rest }, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
739
|
+
return this.httpBackend.createRequest({
|
|
740
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/run_view`),
|
|
741
|
+
method: 'POST',
|
|
742
|
+
}, {
|
|
743
|
+
unparsing_mode,
|
|
744
|
+
...rest,
|
|
825
745
|
});
|
|
826
746
|
}
|
|
827
|
-
getChainId() {
|
|
828
|
-
return
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
method: 'GET',
|
|
832
|
-
});
|
|
747
|
+
async getChainId() {
|
|
748
|
+
return this.httpBackend.createRequest({
|
|
749
|
+
url: this.createURL(`/chains/${this.chain}/chain_id`),
|
|
750
|
+
method: 'GET',
|
|
833
751
|
});
|
|
834
752
|
}
|
|
835
753
|
/**
|
|
836
754
|
* @param data Data to pack
|
|
837
755
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
838
|
-
*
|
|
756
|
+
* Computes the serialized version of a data expression using the same algorithm as script instruction PACK
|
|
839
757
|
* Note: You should always verify the packed bytes before signing or requesting that they be signed when using the RPC to pack.
|
|
840
758
|
* This precaution helps protect you and your applications users from RPC nodes that have been compromised.
|
|
841
759
|
* 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.
|
|
@@ -843,242 +761,226 @@ class RpcClient {
|
|
|
843
761
|
* @example packData({ data: { string: "test" }, type: { prim: "string" } })
|
|
844
762
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
845
763
|
*/
|
|
846
|
-
packData(
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
return Object.assign({ gas: formattedGas }, rest);
|
|
858
|
-
});
|
|
764
|
+
async packData(data, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
765
|
+
const { gas, ...rest } = await this.httpBackend.createRequest({
|
|
766
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/scripts/pack_data`),
|
|
767
|
+
method: 'POST',
|
|
768
|
+
}, data);
|
|
769
|
+
let formattedGas = gas;
|
|
770
|
+
const tryBigNumber = new bignumber_js_1.default(gas || '');
|
|
771
|
+
if (!tryBigNumber.isNaN()) {
|
|
772
|
+
formattedGas = tryBigNumber;
|
|
773
|
+
}
|
|
774
|
+
return { gas: formattedGas, ...rest };
|
|
859
775
|
}
|
|
860
776
|
/**
|
|
861
777
|
*
|
|
862
|
-
*
|
|
778
|
+
* Return rpc root url
|
|
863
779
|
*/
|
|
864
780
|
getRpcUrl() {
|
|
865
781
|
return this.url;
|
|
866
782
|
}
|
|
867
783
|
/**
|
|
868
784
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
869
|
-
*
|
|
785
|
+
* Returns the voting period (index, kind, starting position) and related information (position, remaining) of the interrogated block
|
|
870
786
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-current-period
|
|
871
787
|
*/
|
|
872
|
-
getCurrentPeriod() {
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
method: 'GET',
|
|
877
|
-
});
|
|
878
|
-
return response;
|
|
788
|
+
async getCurrentPeriod({ block, } = rpc_client_interface_1.defaultRPCOptions) {
|
|
789
|
+
const response = await this.httpBackend.createRequest({
|
|
790
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/current_period`),
|
|
791
|
+
method: 'GET',
|
|
879
792
|
});
|
|
793
|
+
return response;
|
|
880
794
|
}
|
|
881
795
|
/**
|
|
882
796
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
883
|
-
*
|
|
797
|
+
* 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
|
|
884
798
|
* @example getSuccessorPeriod() will default to successor voting period for /main/chains/block/head.
|
|
885
799
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-votes-successor-period
|
|
886
800
|
*/
|
|
887
|
-
getSuccessorPeriod() {
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
method: 'GET',
|
|
892
|
-
});
|
|
893
|
-
return response;
|
|
801
|
+
async getSuccessorPeriod({ block, } = rpc_client_interface_1.defaultRPCOptions) {
|
|
802
|
+
const response = await this.httpBackend.createRequest({
|
|
803
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/votes/successor_period`),
|
|
804
|
+
method: 'GET',
|
|
894
805
|
});
|
|
806
|
+
return response;
|
|
895
807
|
}
|
|
896
808
|
/**
|
|
897
809
|
* @param id Sapling state ID
|
|
898
810
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
899
|
-
*
|
|
811
|
+
* Returns the root and a diff of a state starting from an optional offset which is zero by default
|
|
900
812
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-sapling-sapling-state-id-get-diff
|
|
901
813
|
*/
|
|
902
|
-
getSaplingDiffById(
|
|
903
|
-
return
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
method: 'GET',
|
|
907
|
-
});
|
|
814
|
+
async getSaplingDiffById(id, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
815
|
+
return this.httpBackend.createRequest({
|
|
816
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/sapling/${id}/get_diff`),
|
|
817
|
+
method: 'GET',
|
|
908
818
|
});
|
|
909
819
|
}
|
|
910
820
|
/**
|
|
911
821
|
* @param contract address of the contract we want to get the sapling diff
|
|
912
822
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
913
|
-
*
|
|
823
|
+
* Returns the root and a diff of a state starting from an optional offset which is zero by default
|
|
914
824
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-contracts-contract-id-single-sapling-get-diff
|
|
915
825
|
*/
|
|
916
|
-
getSaplingDiffByContract(
|
|
917
|
-
return
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
method: 'GET',
|
|
921
|
-
});
|
|
826
|
+
async getSaplingDiffByContract(contract, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
827
|
+
return this.httpBackend.createRequest({
|
|
828
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/single_sapling_get_diff`),
|
|
829
|
+
method: 'GET',
|
|
922
830
|
});
|
|
923
831
|
}
|
|
924
832
|
/**
|
|
925
833
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
926
|
-
*
|
|
834
|
+
* get current and next protocol
|
|
927
835
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-protocols
|
|
928
836
|
*/
|
|
929
|
-
getProtocols() {
|
|
930
|
-
return
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
method: 'GET',
|
|
934
|
-
});
|
|
837
|
+
async getProtocols({ block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
838
|
+
return this.httpBackend.createRequest({
|
|
839
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/protocols`),
|
|
840
|
+
method: 'GET',
|
|
935
841
|
});
|
|
936
842
|
}
|
|
937
843
|
/**
|
|
938
|
-
* @param
|
|
939
|
-
*
|
|
844
|
+
* @param protocol the protocol hash to look up (default to empty string)
|
|
845
|
+
* get current and next protocol
|
|
940
846
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-protocols
|
|
941
847
|
*/
|
|
942
|
-
getProtocolActivations() {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
throw new utils_2.InvalidProtocolHashError(protocol, protocolValidation);
|
|
948
|
-
}
|
|
848
|
+
async getProtocolActivations(protocol = '') {
|
|
849
|
+
if (protocol) {
|
|
850
|
+
const protocolValidation = (0, utils_2.validateProtocol)(protocol);
|
|
851
|
+
if (protocolValidation !== utils_2.ValidationResult.VALID) {
|
|
852
|
+
throw new utils_2.InvalidProtocolHashError(protocol, protocolValidation);
|
|
949
853
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
854
|
+
}
|
|
855
|
+
return this.httpBackend.createRequest({
|
|
856
|
+
url: this.createURL(`/chains/${this.chain}/protocols/${protocol}`),
|
|
857
|
+
method: 'GET',
|
|
954
858
|
});
|
|
955
859
|
}
|
|
956
860
|
/**
|
|
957
861
|
* @param contract address of the contract we want to retrieve storage information of
|
|
958
862
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
959
|
-
*
|
|
863
|
+
* Access the used storage space of the contract
|
|
960
864
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
961
865
|
*/
|
|
962
|
-
getStorageUsedSpace(
|
|
963
|
-
return
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
method: 'GET',
|
|
967
|
-
});
|
|
866
|
+
async getStorageUsedSpace(contract, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
867
|
+
return this.httpBackend.createRequest({
|
|
868
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/storage/used_space`),
|
|
869
|
+
method: 'GET',
|
|
968
870
|
});
|
|
969
871
|
}
|
|
970
872
|
/**
|
|
971
873
|
* @param contract address of the contract we want to retrieve storage information of
|
|
972
874
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
973
|
-
*
|
|
875
|
+
* Access the paid storage space of the contract
|
|
974
876
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/alpha-openapi.json
|
|
975
877
|
*/
|
|
976
|
-
getStoragePaidSpace(
|
|
977
|
-
return
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
method: 'GET',
|
|
981
|
-
});
|
|
878
|
+
async getStoragePaidSpace(contract, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
879
|
+
return this.httpBackend.createRequest({
|
|
880
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/storage/paid_space`),
|
|
881
|
+
method: 'GET',
|
|
982
882
|
});
|
|
983
883
|
}
|
|
984
884
|
/**
|
|
985
885
|
* @param contract implicit or originated address we want to retrieve ticket balance of
|
|
986
886
|
* @param ticket object to specify a ticket by ticketer, content type and content
|
|
987
887
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
988
|
-
*
|
|
888
|
+
* Access the contract's balance of ticket with specified ticketer, content type, and content.
|
|
989
889
|
* @example ticket { ticketer: 'address', content_type: { prim: "string" }, content: { string: 'ticket1' } }
|
|
990
890
|
* @see https://tezos.gitlab.io/protocols/016_mumbai.html#rpc-changes
|
|
991
891
|
*/
|
|
992
|
-
getTicketBalance(
|
|
993
|
-
return
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
}, ticket);
|
|
998
|
-
});
|
|
892
|
+
async getTicketBalance(contract, ticket, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
893
|
+
return this.httpBackend.createRequest({
|
|
894
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/ticket_balance`),
|
|
895
|
+
method: 'POST',
|
|
896
|
+
}, ticket);
|
|
999
897
|
}
|
|
1000
898
|
/**
|
|
1001
899
|
* @param contract originated address we want to retrieve ticket balances of
|
|
1002
900
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1003
|
-
*
|
|
901
|
+
* Access the complete list of tickets owned by the given contract by scanning the contract's storage.
|
|
1004
902
|
* @see https://tezos.gitlab.io/protocols/016_mumbai.html#rpc-changes
|
|
1005
903
|
*/
|
|
1006
|
-
getAllTicketBalances(
|
|
1007
|
-
return
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
method: 'GET',
|
|
1011
|
-
});
|
|
904
|
+
async getAllTicketBalances(contract, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
905
|
+
return this.httpBackend.createRequest({
|
|
906
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/contracts/${contract}/all_ticket_balances`),
|
|
907
|
+
method: 'GET',
|
|
1012
908
|
});
|
|
1013
909
|
}
|
|
1014
910
|
/**
|
|
1015
|
-
*
|
|
911
|
+
* 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.
|
|
1016
912
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1017
913
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-adaptive-issuance-launch-cycle
|
|
1018
914
|
*/
|
|
1019
|
-
getAdaptiveIssuanceLaunchCycle() {
|
|
1020
|
-
return
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
method: 'GET',
|
|
1024
|
-
});
|
|
915
|
+
async getAdaptiveIssuanceLaunchCycle({ block, } = rpc_client_interface_1.defaultRPCOptions) {
|
|
916
|
+
return this.httpBackend.createRequest({
|
|
917
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/adaptive_issuance_launch_cycle`),
|
|
918
|
+
method: 'GET',
|
|
1025
919
|
});
|
|
1026
920
|
}
|
|
1027
921
|
/**
|
|
1028
|
-
*
|
|
922
|
+
* List the prevalidated operations in mempool (accessibility of mempool depends on each rpc endpoint)
|
|
1029
923
|
* @param args has 5 optional properties
|
|
1030
924
|
* @default args { version: '2', validated: true, refused: true, outdated, true, branchRefused: true, branchDelayed: true, validationPass: undefined, source: undefined, operationHash: undefined }
|
|
1031
925
|
* @see https://gitlab.com/tezos/tezos/-/blob/master/docs/api/tallinn-mempool-openapi-rc.json
|
|
1032
926
|
*/
|
|
1033
|
-
getPendingOperations() {
|
|
1034
|
-
return
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
927
|
+
async getPendingOperations(args = {}) {
|
|
928
|
+
return this.httpBackend.createRequest({
|
|
929
|
+
url: this.createURL(`/chains/${this.chain}/mempool/pending_operations`),
|
|
930
|
+
method: 'GET',
|
|
931
|
+
query: args,
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Returns the current mempool fee filter configuration.
|
|
936
|
+
*
|
|
937
|
+
* On Tezos L1 these values commonly resemble the historical fee defaults used by clients.
|
|
938
|
+
* On Tezos X / Tezlink, the same fields are used for estimation but may differ materially,
|
|
939
|
+
* especially the byte fee and the gas-price component.
|
|
940
|
+
*
|
|
941
|
+
* @param args optional query arguments for the mempool/filter endpoint
|
|
942
|
+
*/
|
|
943
|
+
async getMempoolFilter(args = {}) {
|
|
944
|
+
return this.httpBackend.createRequest({
|
|
945
|
+
url: this.createURL(`/chains/${this.chain}/mempool/filter`),
|
|
946
|
+
method: 'GET',
|
|
947
|
+
query: args,
|
|
1040
948
|
});
|
|
1041
949
|
}
|
|
1042
950
|
/**
|
|
1043
951
|
* @param delegate delegate address which we want to retrieve active staking parameters
|
|
1044
952
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1045
|
-
*
|
|
953
|
+
* Returns the currently active staking parameters for the given delegate
|
|
1046
954
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-active-staking-parameters
|
|
1047
955
|
*/
|
|
1048
|
-
getActiveStakingParameters(
|
|
1049
|
-
return
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
method: 'GET',
|
|
1053
|
-
});
|
|
956
|
+
async getActiveStakingParameters(delegate, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
957
|
+
return await this.httpBackend.createRequest({
|
|
958
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates/${delegate}/active_staking_parameters`),
|
|
959
|
+
method: 'GET',
|
|
1054
960
|
});
|
|
1055
961
|
}
|
|
1056
962
|
/**
|
|
1057
963
|
* @param delegate delegate address which we want to retrieve pending staking parameters
|
|
1058
964
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1059
|
-
*
|
|
965
|
+
* Returns the pending values for the given delegate's staking parameters
|
|
1060
966
|
* @see https://tezos.gitlab.io/active/rpc.html#get-block-id-context-delegates-pkh-pending-staking-parameters
|
|
1061
967
|
*/
|
|
1062
|
-
getPendingStakingParameters(
|
|
1063
|
-
return
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
method: 'GET',
|
|
1067
|
-
});
|
|
968
|
+
async getPendingStakingParameters(delegate, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
969
|
+
return await this.httpBackend.createRequest({
|
|
970
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/delegates/${delegate}/pending_staking_parameters`),
|
|
971
|
+
method: 'GET',
|
|
1068
972
|
});
|
|
1069
973
|
}
|
|
1070
974
|
/**
|
|
1071
975
|
* @param destination address to retrieve the index for
|
|
1072
976
|
* @param options contains generic configuration for rpc calls to specified block (default to head)
|
|
1073
|
-
*
|
|
977
|
+
* Returns the index assigned to the address if it was indexed by the opcode INDEX_ADDRESS, otherwise returns null
|
|
1074
978
|
* @see https://octez.tezos.com/docs/alpha/rpc.html#get-block-id-context-destination-destination-id-index
|
|
1075
979
|
*/
|
|
1076
|
-
getDestinationIndex(
|
|
1077
|
-
return
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
method: 'GET',
|
|
1081
|
-
});
|
|
980
|
+
async getDestinationIndex(destination, { block } = rpc_client_interface_1.defaultRPCOptions) {
|
|
981
|
+
return await this.httpBackend.createRequest({
|
|
982
|
+
url: this.createURL(`/chains/${this.chain}/blocks/${block}/context/destination/${destination}/index`),
|
|
983
|
+
method: 'GET',
|
|
1082
984
|
});
|
|
1083
985
|
}
|
|
1084
986
|
}
|