@taquito/contracts-library 10.2.0-beta-RC.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/LICENSE +7 -0
- package/README.md +30 -0
- package/dist/lib/errors.js +39 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/rpc-wrapper.js +354 -0
- package/dist/lib/rpc-wrapper.js.map +1 -0
- package/dist/lib/taquito-contracts-library.js +88 -0
- package/dist/lib/taquito-contracts-library.js.map +1 -0
- package/dist/lib/version.js +11 -0
- package/dist/lib/version.js.map +1 -0
- package/dist/taquito-contracts-library.es5.js +485 -0
- package/dist/taquito-contracts-library.es5.js.map +1 -0
- package/dist/taquito-contracts-library.umd.js +492 -0
- package/dist/taquito-contracts-library.umd.js.map +1 -0
- package/dist/types/errors.d.ts +6 -0
- package/dist/types/rpc-wrapper.d.ts +48 -0
- package/dist/types/taquito-contracts-library.d.ts +55 -0
- package/dist/types/version.d.ts +4 -0
- package/package.json +107 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@taquito/utils'), require('@taquito/rpc')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@taquito/utils', '@taquito/rpc'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoContractsLibrary = {}, global.utils, global.rpc));
|
|
5
|
+
}(this, (function (exports, utils, rpc) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise */
|
|
22
|
+
|
|
23
|
+
var extendStatics = function(d, b) {
|
|
24
|
+
extendStatics = Object.setPrototypeOf ||
|
|
25
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
27
|
+
return extendStatics(d, b);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function __extends(d, b) {
|
|
31
|
+
if (typeof b !== "function" && b !== null)
|
|
32
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
33
|
+
extendStatics(d, b);
|
|
34
|
+
function __() { this.constructor = d; }
|
|
35
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var __assign = function() {
|
|
39
|
+
__assign = Object.assign || function __assign(t) {
|
|
40
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
41
|
+
s = arguments[i];
|
|
42
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
return __assign.apply(this, arguments);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
50
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
51
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
52
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
53
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
54
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
55
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function __generator(thisArg, body) {
|
|
60
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
61
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
62
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
63
|
+
function step(op) {
|
|
64
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
65
|
+
while (_) try {
|
|
66
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
67
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
68
|
+
switch (op[0]) {
|
|
69
|
+
case 0: case 1: t = op; break;
|
|
70
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
71
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
72
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
73
|
+
default:
|
|
74
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
75
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
76
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
77
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
78
|
+
if (t[2]) _.ops.pop();
|
|
79
|
+
_.trys.pop(); continue;
|
|
80
|
+
}
|
|
81
|
+
op = body.call(thisArg, _);
|
|
82
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
83
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var InvalidAddressError = /** @class */ (function (_super) {
|
|
88
|
+
__extends(InvalidAddressError, _super);
|
|
89
|
+
function InvalidAddressError(message) {
|
|
90
|
+
var _this = _super.call(this, message) || this;
|
|
91
|
+
Object.setPrototypeOf(_this, InvalidAddressError.prototype);
|
|
92
|
+
return _this;
|
|
93
|
+
}
|
|
94
|
+
return InvalidAddressError;
|
|
95
|
+
}(Error));
|
|
96
|
+
var InvalidScriptFormatError = /** @class */ (function (_super) {
|
|
97
|
+
__extends(InvalidScriptFormatError, _super);
|
|
98
|
+
function InvalidScriptFormatError(message) {
|
|
99
|
+
var _this = _super.call(this, message) || this;
|
|
100
|
+
Object.setPrototypeOf(_this, InvalidScriptFormatError.prototype);
|
|
101
|
+
return _this;
|
|
102
|
+
}
|
|
103
|
+
return InvalidScriptFormatError;
|
|
104
|
+
}(Error));
|
|
105
|
+
|
|
106
|
+
var RpcWrapperContractsLibrary = /** @class */ (function () {
|
|
107
|
+
function RpcWrapperContractsLibrary(rpc, contractslibrary) {
|
|
108
|
+
this.rpc = rpc;
|
|
109
|
+
this.contractslibrary = contractslibrary;
|
|
110
|
+
}
|
|
111
|
+
RpcWrapperContractsLibrary.prototype.getScript = function (address, _a) {
|
|
112
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var contractData;
|
|
115
|
+
return __generator(this, function (_c) {
|
|
116
|
+
contractData = this.contractslibrary.getContract(address);
|
|
117
|
+
if (contractData) {
|
|
118
|
+
return [2 /*return*/, contractData.script];
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return [2 /*return*/, this.rpc.getScript(address, { block: block })];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
RpcWrapperContractsLibrary.prototype.getEntrypoints = function (contract, _a) {
|
|
127
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var contractData;
|
|
130
|
+
return __generator(this, function (_c) {
|
|
131
|
+
contractData = this.contractslibrary.getContract(contract);
|
|
132
|
+
if (contractData) {
|
|
133
|
+
return [2 /*return*/, contractData.entrypoints];
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
return [2 /*return*/, this.rpc.getEntrypoints(contract, { block: block })];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
RpcWrapperContractsLibrary.prototype.getBalance = function (address, _a) {
|
|
142
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
return __generator(this, function (_c) {
|
|
145
|
+
return [2 /*return*/, this.rpc.getBalance(address, { block: block })];
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
RpcWrapperContractsLibrary.prototype.getBlockHash = function (_a) {
|
|
150
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
151
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
+
return __generator(this, function (_c) {
|
|
153
|
+
return [2 /*return*/, this.rpc.getBlockHash({ block: block })];
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
RpcWrapperContractsLibrary.prototype.getLiveBlocks = function (_a) {
|
|
158
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
return __generator(this, function (_c) {
|
|
161
|
+
return [2 /*return*/, this.rpc.getLiveBlocks({ block: block })];
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
RpcWrapperContractsLibrary.prototype.getStorage = function (address, _a) {
|
|
166
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
return __generator(this, function (_c) {
|
|
169
|
+
return [2 /*return*/, this.rpc.getStorage(address, { block: block })];
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
RpcWrapperContractsLibrary.prototype.getContract = function (address, _a) {
|
|
174
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
return __generator(this, function (_c) {
|
|
177
|
+
return [2 /*return*/, this.rpc.getContract(address, { block: block })];
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
RpcWrapperContractsLibrary.prototype.getManagerKey = function (address, _a) {
|
|
182
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
return __generator(this, function (_c) {
|
|
185
|
+
return [2 /*return*/, this.rpc.getManagerKey(address, { block: block })];
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
RpcWrapperContractsLibrary.prototype.getDelegate = function (address, _a) {
|
|
190
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
191
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
+
return __generator(this, function (_c) {
|
|
193
|
+
return [2 /*return*/, this.rpc.getDelegate(address, { block: block })];
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
RpcWrapperContractsLibrary.prototype.getBigMapKey = function (address, key, _a) {
|
|
198
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
199
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
200
|
+
return __generator(this, function (_c) {
|
|
201
|
+
return [2 /*return*/, this.rpc.getBigMapKey(address, key, { block: block })];
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
RpcWrapperContractsLibrary.prototype.getBigMapExpr = function (id, expr, _a) {
|
|
206
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
207
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
return __generator(this, function (_c) {
|
|
209
|
+
return [2 /*return*/, this.rpc.getBigMapExpr(id, expr, { block: block })];
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
RpcWrapperContractsLibrary.prototype.getDelegates = function (address, _a) {
|
|
214
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
215
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
216
|
+
return __generator(this, function (_c) {
|
|
217
|
+
return [2 /*return*/, this.rpc.getDelegates(address, { block: block })];
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
RpcWrapperContractsLibrary.prototype.getConstants = function (_a) {
|
|
222
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
223
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
+
return __generator(this, function (_c) {
|
|
225
|
+
return [2 /*return*/, this.rpc.getConstants({ block: block })];
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
RpcWrapperContractsLibrary.prototype.getBlock = function (_a) {
|
|
230
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
return __generator(this, function (_c) {
|
|
233
|
+
return [2 /*return*/, this.rpc.getBlock({ block: block })];
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
RpcWrapperContractsLibrary.prototype.getBlockHeader = function (_a) {
|
|
238
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
239
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
+
return __generator(this, function (_c) {
|
|
241
|
+
return [2 /*return*/, this.rpc.getBlockHeader({ block: block })];
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
RpcWrapperContractsLibrary.prototype.getBlockMetadata = function (_a) {
|
|
246
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
+
return __generator(this, function (_c) {
|
|
249
|
+
return [2 /*return*/, this.rpc.getBlockMetadata({ block: block })];
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
RpcWrapperContractsLibrary.prototype.getBakingRights = function (args, _a) {
|
|
254
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
255
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
+
return __generator(this, function (_c) {
|
|
257
|
+
return [2 /*return*/, this.rpc.getBakingRights(args, { block: block })];
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
RpcWrapperContractsLibrary.prototype.getEndorsingRights = function (args, _a) {
|
|
262
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
263
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
+
return __generator(this, function (_c) {
|
|
265
|
+
return [2 /*return*/, this.rpc.getEndorsingRights(args, { block: block })];
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
RpcWrapperContractsLibrary.prototype.getBallotList = function (_a) {
|
|
270
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
271
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
+
return __generator(this, function (_c) {
|
|
273
|
+
return [2 /*return*/, this.rpc.getBallotList({ block: block })];
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
RpcWrapperContractsLibrary.prototype.getBallots = function (_a) {
|
|
278
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
279
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
280
|
+
return __generator(this, function (_c) {
|
|
281
|
+
return [2 /*return*/, this.rpc.getBallots({ block: block })];
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
RpcWrapperContractsLibrary.prototype.getCurrentPeriodKind = function (_a) {
|
|
286
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
287
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
+
return __generator(this, function (_c) {
|
|
289
|
+
return [2 /*return*/, this.rpc.getCurrentPeriodKind({ block: block })];
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
RpcWrapperContractsLibrary.prototype.getCurrentProposal = function (_a) {
|
|
294
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
295
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
+
return __generator(this, function (_c) {
|
|
297
|
+
return [2 /*return*/, this.rpc.getCurrentProposal({ block: block })];
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
RpcWrapperContractsLibrary.prototype.getCurrentQuorum = function (_a) {
|
|
302
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
303
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
304
|
+
return __generator(this, function (_c) {
|
|
305
|
+
return [2 /*return*/, this.rpc.getCurrentQuorum({ block: block })];
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
RpcWrapperContractsLibrary.prototype.getVotesListings = function (_a) {
|
|
310
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
311
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
312
|
+
return __generator(this, function (_c) {
|
|
313
|
+
return [2 /*return*/, this.rpc.getVotesListings({ block: block })];
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
RpcWrapperContractsLibrary.prototype.getProposals = function (_a) {
|
|
318
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
319
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
320
|
+
return __generator(this, function (_c) {
|
|
321
|
+
return [2 /*return*/, this.rpc.getProposals({ block: block })];
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
RpcWrapperContractsLibrary.prototype.forgeOperations = function (data, _a) {
|
|
326
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
327
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
328
|
+
return __generator(this, function (_c) {
|
|
329
|
+
return [2 /*return*/, this.rpc.forgeOperations(data, { block: block })];
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
RpcWrapperContractsLibrary.prototype.injectOperation = function (signedOpBytes) {
|
|
334
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
335
|
+
return __generator(this, function (_a) {
|
|
336
|
+
return [2 /*return*/, this.rpc.injectOperation(signedOpBytes)];
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
RpcWrapperContractsLibrary.prototype.packData = function (data, _a) {
|
|
341
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
342
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
343
|
+
return __generator(this, function (_c) {
|
|
344
|
+
return [2 /*return*/, this.rpc.packData(data, { block: block })];
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
RpcWrapperContractsLibrary.prototype.preapplyOperations = function (ops, _a) {
|
|
349
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
350
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
351
|
+
return __generator(this, function (_c) {
|
|
352
|
+
return [2 /*return*/, this.rpc.preapplyOperations(ops, { block: block })];
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
RpcWrapperContractsLibrary.prototype.runOperation = function (op, _a) {
|
|
357
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
358
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
359
|
+
return __generator(this, function (_c) {
|
|
360
|
+
return [2 /*return*/, this.rpc.runOperation(op, { block: block })];
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
RpcWrapperContractsLibrary.prototype.runCode = function (code, _a) {
|
|
365
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
366
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
367
|
+
return __generator(this, function (_c) {
|
|
368
|
+
return [2 /*return*/, this.rpc.runCode(code, { block: block })];
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
RpcWrapperContractsLibrary.prototype.getChainId = function () {
|
|
373
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
374
|
+
return __generator(this, function (_a) {
|
|
375
|
+
return [2 /*return*/, this.rpc.getChainId()];
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
RpcWrapperContractsLibrary.prototype.getRpcUrl = function () {
|
|
380
|
+
return this.rpc.getRpcUrl();
|
|
381
|
+
};
|
|
382
|
+
RpcWrapperContractsLibrary.prototype.getCurrentPeriod = function (_a) {
|
|
383
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
384
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
385
|
+
return __generator(this, function (_c) {
|
|
386
|
+
return [2 /*return*/, this.rpc.getCurrentPeriod({ block: block })];
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
RpcWrapperContractsLibrary.prototype.getSuccessorPeriod = function (_a) {
|
|
391
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
392
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
393
|
+
return __generator(this, function (_c) {
|
|
394
|
+
return [2 /*return*/, this.rpc.getSuccessorPeriod({ block: block })];
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
RpcWrapperContractsLibrary.prototype.getSaplingDiffById = function (id, _a) {
|
|
399
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
400
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
401
|
+
return __generator(this, function (_c) {
|
|
402
|
+
return [2 /*return*/, this.rpc.getSaplingDiffById(id, { block: block })];
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
RpcWrapperContractsLibrary.prototype.getSaplingDiffByContract = function (contract, _a) {
|
|
407
|
+
var _b = _a === void 0 ? rpc.defaultRPCOptions : _a, block = _b.block;
|
|
408
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
409
|
+
return __generator(this, function (_c) {
|
|
410
|
+
return [2 /*return*/, this.rpc.getSaplingDiffByContract(contract, { block: block })];
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
return RpcWrapperContractsLibrary;
|
|
415
|
+
}());
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* @packageDocumentation
|
|
419
|
+
* @module @taquito/contracts-library
|
|
420
|
+
*/
|
|
421
|
+
/**
|
|
422
|
+
* @description Allows to specify static data related to contracts (i.e., script and entrypoints) avoiding Taquito to fetch them from the network.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```
|
|
426
|
+
* import { ContractsLibrary } from '@taquito/contracts-library';
|
|
427
|
+
* import { TezosToolkit } from '@taquito/taquito';
|
|
428
|
+
*
|
|
429
|
+
* const Tezos = new TezosToolkit('rpcUrl');
|
|
430
|
+
* const contractsLibrary = new ContractsLibrary();
|
|
431
|
+
*
|
|
432
|
+
* contractsLibrary.addContract({
|
|
433
|
+
* ['contractAddress1']: {
|
|
434
|
+
* script: script1, // obtained from Tezos.rpc.getScript('contractAddress1')
|
|
435
|
+
* entrypoints: entrypoints1 // obtained from Tezos.rpc.getEntrypoints('contractAddress1')
|
|
436
|
+
* },
|
|
437
|
+
* // load more contracts
|
|
438
|
+
* });
|
|
439
|
+
*
|
|
440
|
+
* Tezos.addExtension(contractsLibrary);
|
|
441
|
+
* ```
|
|
442
|
+
*
|
|
443
|
+
*/
|
|
444
|
+
var ContractsLibrary = /** @class */ (function () {
|
|
445
|
+
function ContractsLibrary() {
|
|
446
|
+
this._contractsLibrary = {};
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* @description Saves one of several contract in the library
|
|
450
|
+
*
|
|
451
|
+
* @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.
|
|
452
|
+
* Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by
|
|
453
|
+
* `TezosToolkit.rpc.getScript` and `TezosToolkit.rpc.getEntrypoints`
|
|
454
|
+
*
|
|
455
|
+
*/
|
|
456
|
+
ContractsLibrary.prototype.addContract = function (contract) {
|
|
457
|
+
var _a;
|
|
458
|
+
for (var contractAddress in contract) {
|
|
459
|
+
this.validateContractAddress(contractAddress);
|
|
460
|
+
this.validateContractScriptFormat(contract[contractAddress].script, contractAddress);
|
|
461
|
+
Object.assign(this._contractsLibrary, (_a = {}, _a[contractAddress] = __assign({}, contract[contractAddress]), _a));
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
ContractsLibrary.prototype.getContract = function (contractAddress) {
|
|
465
|
+
return this._contractsLibrary[contractAddress];
|
|
466
|
+
};
|
|
467
|
+
ContractsLibrary.prototype.configureContext = function (context) {
|
|
468
|
+
var _this = this;
|
|
469
|
+
context.registerProviderDecorator(function (context) {
|
|
470
|
+
context.rpc = new RpcWrapperContractsLibrary(context.rpc, _this);
|
|
471
|
+
return context;
|
|
472
|
+
});
|
|
473
|
+
};
|
|
474
|
+
ContractsLibrary.prototype.validateContractAddress = function (address) {
|
|
475
|
+
if (utils.validateAddress(address) !== utils.ValidationResult.VALID) {
|
|
476
|
+
throw new InvalidAddressError("Address is invalid: " + address);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
ContractsLibrary.prototype.validateContractScriptFormat = function (script, address) {
|
|
480
|
+
if (!script.code) {
|
|
481
|
+
throw new InvalidScriptFormatError("An invalid script property has been provided for " + address + ". The script property can be retrieved from TezosToolkit.rpc.getScript(" + address + "). Invalid script: " + script);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
return ContractsLibrary;
|
|
485
|
+
}());
|
|
486
|
+
|
|
487
|
+
exports.ContractsLibrary = ContractsLibrary;
|
|
488
|
+
|
|
489
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
490
|
+
|
|
491
|
+
})));
|
|
492
|
+
//# sourceMappingURL=taquito-contracts-library.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taquito-contracts-library.umd.js","sources":["../src/errors.ts","../src/rpc-wrapper.ts","../src/taquito-contracts-library.ts"],"sourcesContent":["export class InvalidAddressError extends Error {\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, InvalidAddressError.prototype)\n }\n}\n\nexport class InvalidScriptFormatError extends Error {\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, InvalidScriptFormatError.prototype)\n }\n}","import { BigNumber } from 'bignumber.js';\nimport {\n BakingRightsQueryArguments,\n BakingRightsResponse,\n BalanceResponse,\n BallotListResponse,\n BallotsResponse,\n BigMapKey,\n BigMapResponse,\n BlockHeaderResponse,\n BlockMetadata,\n BlockResponse,\n ConstantsResponse,\n ContractResponse,\n CurrentProposalResponse,\n defaultRPCOptions,\n DelegateResponse,\n DelegatesResponse,\n EndorsingRightsQueryArguments,\n EndorsingRightsResponse,\n EntrypointsResponse,\n ForgeOperationsParams,\n ManagerKeyResponse,\n MichelsonV1Expression,\n PackDataParams,\n PeriodKindResponse,\n PreapplyParams,\n PreapplyResponse,\n ProposalsResponse,\n RpcClientInterface,\n RPCOptions,\n RPCRunCodeParam,\n RPCRunOperationParam,\n RunCodeResult,\n SaplingDiffResponse,\n ScriptResponse,\n VotesListingsResponse,\n VotingPeriodBlockResult\n} from '@taquito/rpc';\nimport { ContractsLibrary } from './taquito-contracts-library';\n\nexport class RpcWrapperContractsLibrary implements RpcClientInterface {\n constructor(private rpc: RpcClientInterface, private contractslibrary: ContractsLibrary) {}\n\n async getScript(address: string, { block }: RPCOptions = defaultRPCOptions): Promise<ScriptResponse> {\n const contractData = this.contractslibrary.getContract(address);\n if (contractData){\n return contractData.script;\n } else {\n return this.rpc.getScript(address, { block });\n }\n }\n\n async getEntrypoints(contract: string, { block }: RPCOptions = defaultRPCOptions): Promise<EntrypointsResponse> {\n const contractData = this.contractslibrary.getContract(contract);\n if (contractData){\n return contractData.entrypoints;\n } else {\n return this.rpc.getEntrypoints(contract, { block });\n }\n }\n\n async getBalance(address: string, { block }: RPCOptions = defaultRPCOptions): Promise<BalanceResponse> {\n return this.rpc.getBalance(address, { block });\n }\n async getBlockHash({ block }: RPCOptions = defaultRPCOptions): Promise<string> {\n return this.rpc.getBlockHash({ block });\n }\n async getLiveBlocks({ block }: RPCOptions = defaultRPCOptions): Promise<string[]> {\n return this.rpc.getLiveBlocks({ block });\n }\n async getStorage(address: string, { block }: RPCOptions = defaultRPCOptions): Promise<MichelsonV1Expression> {\n return this.rpc.getStorage(address, { block });\n }\n async getContract(address: string, { block }: RPCOptions = defaultRPCOptions): Promise<ContractResponse> {\n return this.rpc.getContract(address, { block });\n }\n async getManagerKey(address: string, { block }: RPCOptions = defaultRPCOptions): Promise<ManagerKeyResponse> {\n return this.rpc.getManagerKey(address, { block });\n }\n async getDelegate(address: string, { block }: RPCOptions = defaultRPCOptions): Promise<DelegateResponse> {\n return this.rpc.getDelegate(address, { block });\n }\n async getBigMapKey(address: string, key: BigMapKey, { block }: RPCOptions = defaultRPCOptions): Promise<MichelsonV1Expression> {\n return this.rpc.getBigMapKey(address,key, { block });\n }\n async getBigMapExpr(id: string, expr: string, { block }: RPCOptions = defaultRPCOptions): Promise<BigMapResponse> {\n return this.rpc.getBigMapExpr(id, expr, { block });\n }\n async getDelegates(address: string, { block }: RPCOptions = defaultRPCOptions): Promise<DelegatesResponse> {\n return this.rpc.getDelegates(address, { block });\n }\n async getConstants({ block }: RPCOptions = defaultRPCOptions): Promise<ConstantsResponse> {\n return this.rpc.getConstants({ block });\n }\n async getBlock({ block }: RPCOptions = defaultRPCOptions): Promise<BlockResponse> {\n return this.rpc.getBlock({ block });\n }\n async getBlockHeader({ block }: RPCOptions = defaultRPCOptions): Promise<BlockHeaderResponse> {\n return this.rpc.getBlockHeader({ block });\n }\n async getBlockMetadata({ block }: RPCOptions = defaultRPCOptions): Promise<BlockMetadata> {\n return this.rpc.getBlockMetadata({ block });\n }\n async getBakingRights(args: BakingRightsQueryArguments, { block }: RPCOptions = defaultRPCOptions): Promise<BakingRightsResponse> {\n return this.rpc.getBakingRights(args, { block });\n }\n async getEndorsingRights(args: EndorsingRightsQueryArguments, { block }: RPCOptions = defaultRPCOptions): Promise<EndorsingRightsResponse> {\n return this.rpc.getEndorsingRights(args, { block });\n }\n async getBallotList({ block }: RPCOptions = defaultRPCOptions): Promise<BallotListResponse> {\n return this.rpc.getBallotList({ block });\n }\n async getBallots({ block }: RPCOptions = defaultRPCOptions): Promise<BallotsResponse> {\n return this.rpc.getBallots({ block });\n }\n async getCurrentPeriodKind({ block }: RPCOptions = defaultRPCOptions): Promise<PeriodKindResponse> {\n return this.rpc.getCurrentPeriodKind({ block });\n }\n async getCurrentProposal({ block }: RPCOptions = defaultRPCOptions): Promise<CurrentProposalResponse> {\n return this.rpc.getCurrentProposal({ block });\n }\n async getCurrentQuorum({ block }: RPCOptions = defaultRPCOptions): Promise<number> {\n return this.rpc.getCurrentQuorum({ block });\n }\n async getVotesListings({ block }: RPCOptions = defaultRPCOptions): Promise<VotesListingsResponse> {\n return this.rpc.getVotesListings({ block });\n }\n async getProposals({ block }: RPCOptions = defaultRPCOptions): Promise<ProposalsResponse> {\n return this.rpc.getProposals({ block });\n }\n async forgeOperations(data: ForgeOperationsParams, { block }: RPCOptions = defaultRPCOptions): Promise<string> {\n return this.rpc.forgeOperations(data, { block });\n }\n async injectOperation(signedOpBytes: string): Promise<string> {\n return this.rpc.injectOperation(signedOpBytes);\n }\n async packData(data: PackDataParams, { block }: RPCOptions = defaultRPCOptions): Promise<{ packed: string; gas: BigNumber | 'unaccounted' | undefined }> {\n return this.rpc.packData(data, { block })\n }\n async preapplyOperations(ops: PreapplyParams, { block }: RPCOptions = defaultRPCOptions): Promise<PreapplyResponse[]> {\n return this.rpc.preapplyOperations(ops, { block });\n }\n async runOperation(op: RPCRunOperationParam, { block }: RPCOptions = defaultRPCOptions): Promise<PreapplyResponse> {\n return this.rpc.runOperation(op, { block });\n }\n async runCode(code: RPCRunCodeParam, { block }: RPCOptions = defaultRPCOptions): Promise<RunCodeResult> {\n return this.rpc.runCode(code, { block });\n }\n async getChainId(): Promise<string> {\n return this.rpc.getChainId();\n }\n getRpcUrl(): string {\n return this.rpc.getRpcUrl();\n }\n async getCurrentPeriod({ block }: RPCOptions = defaultRPCOptions): Promise<VotingPeriodBlockResult> {\n return this.rpc.getCurrentPeriod({ block });\n }\n async getSuccessorPeriod({ block }: RPCOptions = defaultRPCOptions): Promise<VotingPeriodBlockResult> {\n return this.rpc.getSuccessorPeriod({ block });\n }\n async getSaplingDiffById(id: string, { block }: RPCOptions = defaultRPCOptions): Promise<SaplingDiffResponse> {\n return this.rpc.getSaplingDiffById(id, { block });\n }\n async getSaplingDiffByContract(contract: string, { block }: RPCOptions = defaultRPCOptions): Promise<SaplingDiffResponse> {\n return this.rpc.getSaplingDiffByContract(contract, { block });\n }\n}","/**\n * @packageDocumentation\n * @module @taquito/contracts-library\n */\n\nimport { EntrypointsResponse, ScriptedContracts } from '@taquito/rpc';\nimport { Extension, Context } from '@taquito/taquito';\nimport { validateAddress, ValidationResult } from '@taquito/utils';\nimport { InvalidAddressError, InvalidScriptFormatError } from './errors';\nimport { RpcWrapperContractsLibrary } from './rpc-wrapper';\n\ninterface ContractsData {\n\t[contractAddress: string]: { script: ScriptedContracts; entrypoints: EntrypointsResponse };\n}\n\n/**\n * @description Allows to specify static data related to contracts (i.e., script and entrypoints) avoiding Taquito to fetch them from the network.\n *\n * @example\n * ```\n * import { ContractsLibrary } from '@taquito/contracts-library';\n * import { TezosToolkit } from '@taquito/taquito';\n * \n * const Tezos = new TezosToolkit('rpcUrl');\n * const contractsLibrary = new ContractsLibrary();\n * \n * contractsLibrary.addContract({\n * ['contractAddress1']: {\n * script: script1, // obtained from Tezos.rpc.getScript('contractAddress1')\n * entrypoints: entrypoints1 // obtained from Tezos.rpc.getEntrypoints('contractAddress1')\n * },\n * // load more contracts\n * });\n * \n * Tezos.addExtension(contractsLibrary);\n * ```\n *\n */\nexport class ContractsLibrary implements Extension {\n\tprivate _contractsLibrary: ContractsData = {};\n\n\t/**\n * @description Saves one of several contract in the library\n *\n * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.\n * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by\n * `TezosToolkit.rpc.getScript` and `TezosToolkit.rpc.getEntrypoints`\n *\n */\n\taddContract(contract: ContractsData) {\n\t\tfor (let contractAddress in contract) {\n this.validateContractAddress(contractAddress);\n this.validateContractScriptFormat(contract[contractAddress].script, contractAddress);\n\t\t\tObject.assign(this._contractsLibrary, { [contractAddress]: { ...contract[contractAddress] } });\n\t\t}\n\t}\n\n\tgetContract(contractAddress: string) {\n\t\treturn this._contractsLibrary[contractAddress];\n\t}\n\n\tconfigureContext(context: Context) {\n\t\tcontext.registerProviderDecorator((context: Context) => {\n\t\t\tcontext.rpc = new RpcWrapperContractsLibrary(context.rpc, this);\n\t\t\treturn context;\n\t\t});\n\t}\n\n private validateContractAddress(address: string) {\n if (validateAddress(address) !== ValidationResult.VALID) {\n throw new InvalidAddressError(`Address is invalid: ${address}`);\n }\n }\n \n private validateContractScriptFormat(script: ScriptedContracts, address:string) {\n if(!script.code){\n throw new InvalidScriptFormatError(`An invalid script property has been provided for ${address}. The script property can be retrieved from TezosToolkit.rpc.getScript(${address}). Invalid script: ${script}`)\n }\n }\n}\n"],"names":["defaultRPCOptions","validateAddress","ValidationResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;QAAyC,uCAAK;QAC1C,6BAAY,OAAe;YAA3B,YACI,kBAAM,OAAO,CAAC,SAEjB;YADG,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;;SAC7D;QACL,0BAAC;IAAD,CALA,CAAyC,KAAK,GAK7C;IAED;QAA8C,4CAAK;QAC/C,kCAAY,OAAe;YAA3B,YACI,kBAAM,OAAO,CAAC,SAEjB;YADG,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAA;;SAClE;QAC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AC,IAAI,EAAC;gBACZ,MAAM,IAAI,wBAAwB,CAAC,sDAAoD,OAAO,+EAA0E,OAAO,2BAAsB,MAAQ,CAAC,CAAA;aACjN;SACJ;QACP,uBAAC;IAAD,CAAC;;;;;;;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BigNumber } from 'bignumber.js';
|
|
2
|
+
import { BakingRightsQueryArguments, BakingRightsResponse, BalanceResponse, BallotListResponse, BallotsResponse, BigMapKey, BigMapResponse, BlockHeaderResponse, BlockMetadata, BlockResponse, ConstantsResponse, ContractResponse, CurrentProposalResponse, DelegateResponse, DelegatesResponse, EndorsingRightsQueryArguments, EndorsingRightsResponse, EntrypointsResponse, ForgeOperationsParams, ManagerKeyResponse, MichelsonV1Expression, PackDataParams, PeriodKindResponse, PreapplyParams, PreapplyResponse, ProposalsResponse, RpcClientInterface, RPCOptions, RPCRunCodeParam, RPCRunOperationParam, RunCodeResult, SaplingDiffResponse, ScriptResponse, VotesListingsResponse, VotingPeriodBlockResult } from '@taquito/rpc';
|
|
3
|
+
import { ContractsLibrary } from './taquito-contracts-library';
|
|
4
|
+
export declare class RpcWrapperContractsLibrary implements RpcClientInterface {
|
|
5
|
+
private rpc;
|
|
6
|
+
private contractslibrary;
|
|
7
|
+
constructor(rpc: RpcClientInterface, contractslibrary: ContractsLibrary);
|
|
8
|
+
getScript(address: string, { block }?: RPCOptions): Promise<ScriptResponse>;
|
|
9
|
+
getEntrypoints(contract: string, { block }?: RPCOptions): Promise<EntrypointsResponse>;
|
|
10
|
+
getBalance(address: string, { block }?: RPCOptions): Promise<BalanceResponse>;
|
|
11
|
+
getBlockHash({ block }?: RPCOptions): Promise<string>;
|
|
12
|
+
getLiveBlocks({ block }?: RPCOptions): Promise<string[]>;
|
|
13
|
+
getStorage(address: string, { block }?: RPCOptions): Promise<MichelsonV1Expression>;
|
|
14
|
+
getContract(address: string, { block }?: RPCOptions): Promise<ContractResponse>;
|
|
15
|
+
getManagerKey(address: string, { block }?: RPCOptions): Promise<ManagerKeyResponse>;
|
|
16
|
+
getDelegate(address: string, { block }?: RPCOptions): Promise<DelegateResponse>;
|
|
17
|
+
getBigMapKey(address: string, key: BigMapKey, { block }?: RPCOptions): Promise<MichelsonV1Expression>;
|
|
18
|
+
getBigMapExpr(id: string, expr: string, { block }?: RPCOptions): Promise<BigMapResponse>;
|
|
19
|
+
getDelegates(address: string, { block }?: RPCOptions): Promise<DelegatesResponse>;
|
|
20
|
+
getConstants({ block }?: RPCOptions): Promise<ConstantsResponse>;
|
|
21
|
+
getBlock({ block }?: RPCOptions): Promise<BlockResponse>;
|
|
22
|
+
getBlockHeader({ block }?: RPCOptions): Promise<BlockHeaderResponse>;
|
|
23
|
+
getBlockMetadata({ block }?: RPCOptions): Promise<BlockMetadata>;
|
|
24
|
+
getBakingRights(args: BakingRightsQueryArguments, { block }?: RPCOptions): Promise<BakingRightsResponse>;
|
|
25
|
+
getEndorsingRights(args: EndorsingRightsQueryArguments, { block }?: RPCOptions): Promise<EndorsingRightsResponse>;
|
|
26
|
+
getBallotList({ block }?: RPCOptions): Promise<BallotListResponse>;
|
|
27
|
+
getBallots({ block }?: RPCOptions): Promise<BallotsResponse>;
|
|
28
|
+
getCurrentPeriodKind({ block }?: RPCOptions): Promise<PeriodKindResponse>;
|
|
29
|
+
getCurrentProposal({ block }?: RPCOptions): Promise<CurrentProposalResponse>;
|
|
30
|
+
getCurrentQuorum({ block }?: RPCOptions): Promise<number>;
|
|
31
|
+
getVotesListings({ block }?: RPCOptions): Promise<VotesListingsResponse>;
|
|
32
|
+
getProposals({ block }?: RPCOptions): Promise<ProposalsResponse>;
|
|
33
|
+
forgeOperations(data: ForgeOperationsParams, { block }?: RPCOptions): Promise<string>;
|
|
34
|
+
injectOperation(signedOpBytes: string): Promise<string>;
|
|
35
|
+
packData(data: PackDataParams, { block }?: RPCOptions): Promise<{
|
|
36
|
+
packed: string;
|
|
37
|
+
gas: BigNumber | 'unaccounted' | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
preapplyOperations(ops: PreapplyParams, { block }?: RPCOptions): Promise<PreapplyResponse[]>;
|
|
40
|
+
runOperation(op: RPCRunOperationParam, { block }?: RPCOptions): Promise<PreapplyResponse>;
|
|
41
|
+
runCode(code: RPCRunCodeParam, { block }?: RPCOptions): Promise<RunCodeResult>;
|
|
42
|
+
getChainId(): Promise<string>;
|
|
43
|
+
getRpcUrl(): string;
|
|
44
|
+
getCurrentPeriod({ block }?: RPCOptions): Promise<VotingPeriodBlockResult>;
|
|
45
|
+
getSuccessorPeriod({ block }?: RPCOptions): Promise<VotingPeriodBlockResult>;
|
|
46
|
+
getSaplingDiffById(id: string, { block }?: RPCOptions): Promise<SaplingDiffResponse>;
|
|
47
|
+
getSaplingDiffByContract(contract: string, { block }?: RPCOptions): Promise<SaplingDiffResponse>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module @taquito/contracts-library
|
|
4
|
+
*/
|
|
5
|
+
import { EntrypointsResponse, ScriptedContracts } from '@taquito/rpc';
|
|
6
|
+
import { Extension, Context } from '@taquito/taquito';
|
|
7
|
+
interface ContractsData {
|
|
8
|
+
[contractAddress: string]: {
|
|
9
|
+
script: ScriptedContracts;
|
|
10
|
+
entrypoints: EntrypointsResponse;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @description Allows to specify static data related to contracts (i.e., script and entrypoints) avoiding Taquito to fetch them from the network.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```
|
|
18
|
+
* import { ContractsLibrary } from '@taquito/contracts-library';
|
|
19
|
+
* import { TezosToolkit } from '@taquito/taquito';
|
|
20
|
+
*
|
|
21
|
+
* const Tezos = new TezosToolkit('rpcUrl');
|
|
22
|
+
* const contractsLibrary = new ContractsLibrary();
|
|
23
|
+
*
|
|
24
|
+
* contractsLibrary.addContract({
|
|
25
|
+
* ['contractAddress1']: {
|
|
26
|
+
* script: script1, // obtained from Tezos.rpc.getScript('contractAddress1')
|
|
27
|
+
* entrypoints: entrypoints1 // obtained from Tezos.rpc.getEntrypoints('contractAddress1')
|
|
28
|
+
* },
|
|
29
|
+
* // load more contracts
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* Tezos.addExtension(contractsLibrary);
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
export declare class ContractsLibrary implements Extension {
|
|
37
|
+
private _contractsLibrary;
|
|
38
|
+
/**
|
|
39
|
+
* @description Saves one of several contract in the library
|
|
40
|
+
*
|
|
41
|
+
* @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.
|
|
42
|
+
* Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by
|
|
43
|
+
* `TezosToolkit.rpc.getScript` and `TezosToolkit.rpc.getEntrypoints`
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
addContract(contract: ContractsData): void;
|
|
47
|
+
getContract(contractAddress: string): {
|
|
48
|
+
script: ScriptedContracts;
|
|
49
|
+
entrypoints: EntrypointsResponse;
|
|
50
|
+
};
|
|
51
|
+
configureContext(context: Context): void;
|
|
52
|
+
private validateContractAddress;
|
|
53
|
+
private validateContractScriptFormat;
|
|
54
|
+
}
|
|
55
|
+
export {};
|