@airgap/coinlib-core 0.13.6-beta.1 → 0.13.6-beta.11
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/airgap-coinlib-core.min.js +1199 -2583
- package/index.d.ts +3 -2
- package/index.js +5 -4
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/protocols/tezos/TezosProtocol.d.ts +3 -19
- package/protocols/tezos/TezosProtocol.js +25 -365
- package/protocols/tezos/TezosProtocol.js.map +1 -1
- package/protocols/tezos/TezosProtocolOptions.d.ts +5 -7
- package/protocols/tezos/TezosProtocolOptions.js +14 -28
- package/protocols/tezos/TezosProtocolOptions.js.map +1 -1
- package/protocols/tezos/contract/TezosContract.d.ts +9 -7
- package/protocols/tezos/contract/TezosContract.js +63 -84
- package/protocols/tezos/contract/TezosContract.js.map +1 -1
- package/protocols/tezos/contract/TezosContractEntrypoint.js +1 -1
- package/protocols/tezos/contract/TezosContractEntrypoint.js.map +1 -1
- package/protocols/tezos/domains/TezosDomains.d.ts +2 -2
- package/protocols/tezos/domains/TezosDomains.js +36 -27
- package/protocols/tezos/domains/TezosDomains.js.map +1 -1
- package/protocols/tezos/fa/TezosBTC.d.ts +0 -1
- package/protocols/tezos/fa/TezosBTC.js +1 -43
- package/protocols/tezos/fa/TezosBTC.js.map +1 -1
- package/protocols/tezos/fa/TezosETHtz.d.ts +0 -1
- package/protocols/tezos/fa/TezosETHtz.js +1 -40
- package/protocols/tezos/fa/TezosETHtz.js.map +1 -1
- package/protocols/tezos/fa/TezosFA1Protocol.js +1 -2
- package/protocols/tezos/fa/TezosFA1Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFA2Protocol.d.ts +0 -3
- package/protocols/tezos/fa/TezosFA2Protocol.js +31 -108
- package/protocols/tezos/fa/TezosFA2Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFAProtocol.d.ts +2 -6
- package/protocols/tezos/fa/TezosFAProtocol.js +29 -167
- package/protocols/tezos/fa/TezosFAProtocol.js.map +1 -1
- package/protocols/tezos/fa/TezosKolibriUSD.d.ts +0 -1
- package/protocols/tezos/fa/TezosKolibriUSD.js +1 -40
- package/protocols/tezos/fa/TezosKolibriUSD.js.map +1 -1
- package/protocols/tezos/fa/TezosStaker.js +1 -15
- package/protocols/tezos/fa/TezosStaker.js.map +1 -1
- package/protocols/tezos/fa/TezosUSD.d.ts +0 -1
- package/protocols/tezos/fa/TezosUSD.js +1 -38
- package/protocols/tezos/fa/TezosUSD.js.map +1 -1
- package/protocols/tezos/fa/TezosWrapped.js +1 -36
- package/protocols/tezos/fa/TezosWrapped.js.map +1 -1
- package/protocols/tezos/indexerClient/TezosIndexerClient.d.ts +25 -0
- package/protocols/tezos/indexerClient/TezosIndexerClient.js +251 -0
- package/protocols/tezos/indexerClient/TezosIndexerClient.js.map +1 -0
- package/protocols/tezos/indexerClient/TezosProtocolIndexerClient.d.ts +26 -0
- package/protocols/tezos/indexerClient/TezosProtocolIndexerClient.js +3 -0
- package/protocols/tezos/indexerClient/TezosProtocolIndexerClient.js.map +1 -0
- package/protocols/tezos/kt/TezosKtProtocol.js +3 -33
- package/protocols/tezos/kt/TezosKtProtocol.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingProtocol.js +8 -3
- package/protocols/tezos/sapling/TezosSaplingProtocol.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingProtocolOptions.js +5 -1
- package/protocols/tezos/sapling/TezosSaplingProtocolOptions.js.map +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingForger.js +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingForger.js.map +1 -1
- package/protocols/tezos/types/TezosTransactionCursor.d.ts +1 -1
- package/protocols/tezos/types/contract/BigMap.d.ts +7 -0
- package/protocols/tezos/types/contract/{BigMapResult.js → BigMap.js} +1 -1
- package/protocols/tezos/types/contract/BigMap.js.map +1 -0
- package/protocols/tezos/types/contract/BigMapEnrtyFilter.d.ts +5 -0
- package/protocols/tezos/types/contract/{ConseilPredicate.js → BigMapEnrtyFilter.js} +1 -1
- package/protocols/tezos/types/contract/BigMapEnrtyFilter.js.map +1 -0
- package/protocols/tezos/types/contract/BigMapEntry.d.ts +7 -0
- package/protocols/tezos/types/contract/{BigMapPredicate.js → BigMapEntry.js} +1 -1
- package/protocols/tezos/types/contract/BigMapEntry.js.map +1 -0
- package/protocols/tezos/types/contract/BigMapRequest.d.ts +5 -4
- package/protocols/tezos/types/micheline/MichelineNodeUtils.js +1 -1
- package/protocols/tezos/types/micheline/MichelineNodeUtils.js.map +1 -1
- package/protocols/tezos/types/michelson/MichelsonTypeMeta.js +2 -2
- package/protocols/tezos/types/michelson/MichelsonTypeMeta.js.map +1 -1
- package/protocols/tezos/types/michelson/generics/MichelsonMap.js +1 -1
- package/protocols/tezos/types/michelson/generics/MichelsonMap.js.map +1 -1
- package/protocols/tezos/types/michelson/generics/MichelsonOption.js +1 -1
- package/protocols/tezos/types/michelson/generics/MichelsonOption.js.map +1 -1
- package/protocols/tezos/types/michelson/generics/MichelsonOr.js +2 -2
- package/protocols/tezos/types/michelson/generics/MichelsonOr.js.map +1 -1
- package/protocols/tezos/types/michelson/generics/MichelsonPair.js +2 -2
- package/protocols/tezos/types/michelson/generics/MichelsonPair.js.map +1 -1
- package/protocols/tezos/types/michelson/primitives/MichelsonBool.js +1 -1
- package/protocols/tezos/types/michelson/primitives/MichelsonBool.js.map +1 -1
- package/protocols/tezos/types/michelson/primitives/MichelsonUnit.js +1 -1
- package/protocols/tezos/types/michelson/primitives/MichelsonUnit.js.map +1 -1
- package/protocols/tezos/types/sapling/TezosSaplingOutput.d.ts +1 -0
- package/protocols/tezos/types/utils.d.ts +4 -1
- package/protocols/tezos/types/utils.js +7 -3
- package/protocols/tezos/types/utils.js.map +1 -1
- package/serializer/schemas/definitions/unsigned-transaction-tezos-sapling.d.ts +1 -0
- package/serializer-v3/schemas/definitions/unsigned-transaction-tezos-sapling.d.ts +1 -0
- package/serializer-v3/schemas/generated/transaction-sign-request-tezos-sapling.json +4 -1
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation005.d.ts +0 -14
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation005.js +0 -164
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation005.js.map +0 -1
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation006.d.ts +0 -9
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation006.js +0 -51
- package/protocols/tezos/rewardcalculation/TezosRewardCalculation006.js.map +0 -1
- package/protocols/tezos/rewardcalculation/TezosRewardCalculationDefault.d.ts +0 -36
- package/protocols/tezos/rewardcalculation/TezosRewardCalculationDefault.js +0 -642
- package/protocols/tezos/rewardcalculation/TezosRewardCalculationDefault.js.map +0 -1
- package/protocols/tezos/types/contract/BigMapPredicate.d.ts +0 -4
- package/protocols/tezos/types/contract/BigMapPredicate.js.map +0 -1
- package/protocols/tezos/types/contract/BigMapResult.d.ts +0 -6
- package/protocols/tezos/types/contract/BigMapResult.js.map +0 -1
- package/protocols/tezos/types/contract/ConseilPredicate.d.ts +0 -7
- package/protocols/tezos/types/contract/ConseilPredicate.js.map +0 -1
|
@@ -90,13 +90,9 @@ var bignumber_1 = __importDefault(require("../../dependencies/src/bignumber.js-9
|
|
|
90
90
|
var index_2 = require("../../dependencies/src/bip39-2.5.0/index");
|
|
91
91
|
var bs58check = __importStar(require("../../dependencies/src/bs58check-2.1.2/index"));
|
|
92
92
|
var index_3 = require("../../dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/index");
|
|
93
|
-
var IAirGapTransaction_1 = require("../../interfaces/IAirGapTransaction");
|
|
94
93
|
var ProtocolSymbols_1 = require("../../utils/ProtocolSymbols");
|
|
95
94
|
var subProtocols_1 = require("../../utils/subProtocols");
|
|
96
95
|
var NonExtendedProtocol_1 = require("../NonExtendedProtocol");
|
|
97
|
-
var TezosRewardCalculation005_1 = require("./rewardcalculation/TezosRewardCalculation005");
|
|
98
|
-
var TezosRewardCalculation006_1 = require("./rewardcalculation/TezosRewardCalculation006");
|
|
99
|
-
var TezosRewardCalculationDefault_1 = require("./rewardcalculation/TezosRewardCalculationDefault");
|
|
100
96
|
var TezosAddress_1 = require("./TezosAddress");
|
|
101
97
|
var TezosCryptoClient_1 = require("./TezosCryptoClient");
|
|
102
98
|
var TezosProtocolOptions_1 = require("./TezosProtocolOptions");
|
|
@@ -124,8 +120,7 @@ var SELF_BOND_REQUIREMENT = 0.0825;
|
|
|
124
120
|
var TezosNetwork;
|
|
125
121
|
(function (TezosNetwork) {
|
|
126
122
|
TezosNetwork["MAINNET"] = "mainnet";
|
|
127
|
-
TezosNetwork["
|
|
128
|
-
TezosNetwork["JAKARTANET"] = "jakartanet";
|
|
123
|
+
TezosNetwork["GHOSTNET"] = "ghostnet";
|
|
129
124
|
})(TezosNetwork = exports.TezosNetwork || (exports.TezosNetwork = {}));
|
|
130
125
|
var TezosProtocol = /** @class */ (function (_super) {
|
|
131
126
|
__extends(TezosProtocol, _super);
|
|
@@ -167,13 +162,6 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
167
162
|
_this.activationBurn = _this.originationSize.times(_this.storageCostPerByte);
|
|
168
163
|
_this.originationBurn = _this.originationSize.times(_this.storageCostPerByte); // https://tezos.stackexchange.com/a/787
|
|
169
164
|
_this.cryptoClient = new TezosCryptoClient_1.TezosCryptoClient(TezosUtils_1.TezosUtils.tezosPrefixes.edsig);
|
|
170
|
-
_this.headers = { 'Content-Type': 'application/json', apiKey: 'airgap00391' };
|
|
171
|
-
_this.rewardCalculations = {
|
|
172
|
-
alpha: new TezosRewardCalculationDefault_1.TezosRewardsCalculationDefault(_this),
|
|
173
|
-
babylon: new TezosRewardCalculation005_1.TezosRewardsCalculation005(_this),
|
|
174
|
-
cartha: new TezosRewardCalculation006_1.TezosRewardsCalculation006(_this)
|
|
175
|
-
};
|
|
176
|
-
_this.headers.apiKey = options.network.extras.conseilApiKey;
|
|
177
165
|
return _this;
|
|
178
166
|
}
|
|
179
167
|
Object.defineProperty(TezosProtocol.prototype, "subProtocols", {
|
|
@@ -191,20 +179,6 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
191
179
|
enumerable: false,
|
|
192
180
|
configurable: true
|
|
193
181
|
});
|
|
194
|
-
Object.defineProperty(TezosProtocol.prototype, "baseApiUrl", {
|
|
195
|
-
get: function () {
|
|
196
|
-
return this.options.network.extras.conseilUrl;
|
|
197
|
-
},
|
|
198
|
-
enumerable: false,
|
|
199
|
-
configurable: true
|
|
200
|
-
});
|
|
201
|
-
Object.defineProperty(TezosProtocol.prototype, "baseApiNetwork", {
|
|
202
|
-
get: function () {
|
|
203
|
-
return this.options.network.extras.conseilNetwork;
|
|
204
|
-
},
|
|
205
|
-
enumerable: false,
|
|
206
|
-
configurable: true
|
|
207
|
-
});
|
|
208
182
|
TezosProtocol.prototype.getBlockExplorerLinkForAddress = function (address) {
|
|
209
183
|
return __awaiter(this, void 0, void 0, function () {
|
|
210
184
|
return __generator(this, function (_a) {
|
|
@@ -310,112 +284,21 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
310
284
|
});
|
|
311
285
|
};
|
|
312
286
|
TezosProtocol.prototype.getTransactionsFromAddresses = function (addresses, limit, cursor) {
|
|
287
|
+
var _a;
|
|
313
288
|
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
-
var
|
|
289
|
+
var address, results;
|
|
315
290
|
var _this = this;
|
|
316
|
-
return __generator(this, function (
|
|
317
|
-
switch (
|
|
318
|
-
case 0:
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
fields: ['status', 'amount', 'fee', 'source', 'destination', 'operation_group_hash', 'timestamp', 'block_level'],
|
|
322
|
-
predicates: [
|
|
323
|
-
{
|
|
324
|
-
field: 'source',
|
|
325
|
-
operation: 'eq',
|
|
326
|
-
set: [address],
|
|
327
|
-
inverse: false,
|
|
328
|
-
group: 'a'
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
field: 'destination',
|
|
332
|
-
operation: 'eq',
|
|
333
|
-
set: [address],
|
|
334
|
-
inverse: false,
|
|
335
|
-
group: 'b'
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
field: 'kind',
|
|
339
|
-
operation: 'eq',
|
|
340
|
-
set: ['transaction'],
|
|
341
|
-
inverse: false,
|
|
342
|
-
group: 'a'
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
field: 'kind',
|
|
346
|
-
operation: 'eq',
|
|
347
|
-
set: ['transaction'],
|
|
348
|
-
inverse: false,
|
|
349
|
-
group: 'b'
|
|
350
|
-
}
|
|
351
|
-
],
|
|
352
|
-
orderBy: [
|
|
353
|
-
{
|
|
354
|
-
field: 'block_level',
|
|
355
|
-
direction: 'desc'
|
|
356
|
-
}
|
|
357
|
-
],
|
|
358
|
-
limit: limit
|
|
359
|
-
};
|
|
360
|
-
if (cursor && cursor.lastBlockLevel) {
|
|
361
|
-
body.predicates.push({
|
|
362
|
-
field: 'block_level',
|
|
363
|
-
operation: 'lt',
|
|
364
|
-
set: [cursor.lastBlockLevel.toString()],
|
|
365
|
-
inverse: false,
|
|
366
|
-
group: 'a'
|
|
367
|
-
});
|
|
368
|
-
body.predicates.push({
|
|
369
|
-
field: 'block_level',
|
|
370
|
-
operation: 'lt',
|
|
371
|
-
set: [cursor.lastBlockLevel.toString()],
|
|
372
|
-
inverse: false,
|
|
373
|
-
group: 'b'
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
return body;
|
|
377
|
-
};
|
|
378
|
-
// AirGapTransactionStatus.APPLIED : AirGapTransactionStatus.FAILED
|
|
379
|
-
return new Promise(function (resolve, _reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
380
|
-
var result;
|
|
381
|
-
return __generator(this, function (_a) {
|
|
382
|
-
switch (_a.label) {
|
|
383
|
-
case 0: return [4 /*yield*/, index_1.default
|
|
384
|
-
.post(this.options.network.extras.conseilUrl + "/v2/data/tezos/" + this.options.network.extras.conseilNetwork + "/operations", getRequestBody(), {
|
|
385
|
-
headers: this.headers
|
|
386
|
-
})
|
|
387
|
-
.catch(function () {
|
|
388
|
-
return { data: [] };
|
|
389
|
-
})];
|
|
390
|
-
case 1:
|
|
391
|
-
result = _a.sent();
|
|
392
|
-
resolve(result.data);
|
|
393
|
-
return [2 /*return*/];
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
}); });
|
|
397
|
-
}))];
|
|
291
|
+
return __generator(this, function (_b) {
|
|
292
|
+
switch (_b.label) {
|
|
293
|
+
case 0:
|
|
294
|
+
address = addresses[0];
|
|
295
|
+
return [4 /*yield*/, this.options.network.extras.indexerClient.getTransactions(address, limit, cursor === null || cursor === void 0 ? void 0 : cursor.offset)];
|
|
398
296
|
case 1:
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
amount: new bignumber_1.default(transaction.amount),
|
|
405
|
-
fee: new bignumber_1.default(transaction.fee),
|
|
406
|
-
from: [transaction.source],
|
|
407
|
-
isInbound: addresses.indexOf(transaction.destination) !== -1,
|
|
408
|
-
protocolIdentifier: _this.identifier,
|
|
409
|
-
network: _this.options.network,
|
|
410
|
-
to: [transaction.destination],
|
|
411
|
-
hash: transaction.operation_group_hash,
|
|
412
|
-
timestamp: transaction.timestamp / 1000,
|
|
413
|
-
blockHeight: transaction.block_level,
|
|
414
|
-
status: transaction.status === 'applied' ? IAirGapTransaction_1.AirGapTransactionStatus.APPLIED : IAirGapTransaction_1.AirGapTransactionStatus.FAILED
|
|
415
|
-
};
|
|
416
|
-
});
|
|
417
|
-
lastEntryBlockLevel = allTransactions.length > 0 ? allTransactions[allTransactions.length - 1].blockHeight : 0;
|
|
418
|
-
return [2 /*return*/, { transactions: allTransactions, cursor: { lastBlockLevel: lastEntryBlockLevel } }];
|
|
297
|
+
results = _b.sent();
|
|
298
|
+
return [2 /*return*/, {
|
|
299
|
+
transactions: results.map(function (transaction) { return (__assign(__assign({}, transaction), { protocolIdentifier: _this.identifier, network: _this.options.network })); }),
|
|
300
|
+
cursor: { offset: ((_a = cursor === null || cursor === void 0 ? void 0 : cursor.offset) !== null && _a !== void 0 ? _a : 0) + results.length }
|
|
301
|
+
}];
|
|
419
302
|
}
|
|
420
303
|
});
|
|
421
304
|
});
|
|
@@ -536,7 +419,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
536
419
|
return [3 /*break*/, 8];
|
|
537
420
|
case 6: throw new index_4.UnsupportedError(coinlib_error_1.Domain.TEZOS, 'operation not supported: ' + JSON.stringify(tezosOperation.kind));
|
|
538
421
|
case 7:
|
|
539
|
-
assertNever(tezosOperation.kind);
|
|
422
|
+
assertNever(tezosOperation.kind);
|
|
540
423
|
throw new index_4.NotFoundError(coinlib_error_1.Domain.TEZOS, 'no operation to unforge found');
|
|
541
424
|
case 8: return [2 /*return*/, partialTxs.map(function (partialTx) {
|
|
542
425
|
return __assign({ amount: '0', fee: operation !== undefined ? new bignumber_1.default(operation.fee).toString(10) : '0', from: [], isInbound: false, protocolIdentifier: _this.identifier, network: _this.options.network, to: [], transactionDetails: tezosOperation }, partialTx);
|
|
@@ -1347,7 +1230,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1347
1230
|
if (internalOperation.result.errors) {
|
|
1348
1231
|
throw new index_4.TransactionError(coinlib_error_1.Domain.TEZOS, 'An internal operation produced an error', internalOperation.result.errors);
|
|
1349
1232
|
}
|
|
1350
|
-
gasLimit_1 += Number(internalOperation.result.
|
|
1233
|
+
gasLimit_1 += Math.ceil(Number(internalOperation.result.consumed_milligas) / 1000);
|
|
1351
1234
|
if (internalOperation.result.paid_storage_size_diff) {
|
|
1352
1235
|
storageLimit_1 += Number(internalOperation.result.paid_storage_size_diff);
|
|
1353
1236
|
}
|
|
@@ -1364,7 +1247,7 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1364
1247
|
throw new index_4.TransactionError(coinlib_error_1.Domain.TEZOS, 'The operation produced an error', result.errors);
|
|
1365
1248
|
}
|
|
1366
1249
|
// Add gas and storage used by operation
|
|
1367
|
-
gasLimit_1 += Number(result.
|
|
1250
|
+
gasLimit_1 += Math.ceil(Number(result.consumed_milligas) / 1000);
|
|
1368
1251
|
if (result.paid_storage_size_diff) {
|
|
1369
1252
|
storageLimit_1 += Number(result.paid_storage_size_diff);
|
|
1370
1253
|
}
|
|
@@ -1409,70 +1292,19 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1409
1292
|
TezosProtocol.prototype.getDelegationInfo = function (delegatedAddress, fetchExtraInfo) {
|
|
1410
1293
|
if (fetchExtraInfo === void 0) { fetchExtraInfo = true; }
|
|
1411
1294
|
return __awaiter(this, void 0, void 0, function () {
|
|
1412
|
-
var data, delegatedOpLevel, delegatedDate,
|
|
1295
|
+
var data, delegatedOpLevel, delegatedDate, recentTransactionData;
|
|
1413
1296
|
return __generator(this, function (_a) {
|
|
1414
1297
|
switch (_a.label) {
|
|
1415
1298
|
case 0: return [4 /*yield*/, index_1.default.get(this.options.network.rpcUrl + "/chains/main/blocks/head/context/contracts/" + delegatedAddress)];
|
|
1416
1299
|
case 1:
|
|
1417
1300
|
data = (_a.sent()).data;
|
|
1418
1301
|
if (!(data.delegate && fetchExtraInfo)) return [3 /*break*/, 3];
|
|
1419
|
-
|
|
1420
|
-
if (transactions.length > 0) {
|
|
1421
|
-
var mostRecentTransaction = transactions[0];
|
|
1422
|
-
return {
|
|
1423
|
-
date: new Date(mostRecentTransaction.timestamp),
|
|
1424
|
-
opLevel: mostRecentTransaction.block_level
|
|
1425
|
-
};
|
|
1426
|
-
}
|
|
1427
|
-
};
|
|
1428
|
-
getRequestBody = function (field, set) {
|
|
1429
|
-
return {
|
|
1430
|
-
predicates: [
|
|
1431
|
-
{
|
|
1432
|
-
field: field,
|
|
1433
|
-
operation: 'eq',
|
|
1434
|
-
set: [delegatedAddress],
|
|
1435
|
-
inverse: false
|
|
1436
|
-
},
|
|
1437
|
-
{
|
|
1438
|
-
field: 'kind',
|
|
1439
|
-
operation: 'eq',
|
|
1440
|
-
set: [set],
|
|
1441
|
-
inverse: false
|
|
1442
|
-
}
|
|
1443
|
-
],
|
|
1444
|
-
orderBy: [
|
|
1445
|
-
{
|
|
1446
|
-
field: 'block_level',
|
|
1447
|
-
direction: 'desc'
|
|
1448
|
-
}
|
|
1449
|
-
]
|
|
1450
|
-
};
|
|
1451
|
-
};
|
|
1452
|
-
transactionSourceUrl = this.options.network.extras.conseilUrl + "/v2/data/tezos/" + this.options.network.extras.conseilNetwork + "/operations";
|
|
1453
|
-
return [4 /*yield*/, Promise.all([
|
|
1454
|
-
index_1.default
|
|
1455
|
-
.post(transactionSourceUrl, getRequestBody('source', 'delegation'), {
|
|
1456
|
-
headers: this.headers
|
|
1457
|
-
})
|
|
1458
|
-
.catch(function () {
|
|
1459
|
-
return { data: [] };
|
|
1460
|
-
}),
|
|
1461
|
-
index_1.default
|
|
1462
|
-
.post(transactionSourceUrl, getRequestBody('manager_pubkey', 'origination'), {
|
|
1463
|
-
headers: this.headers
|
|
1464
|
-
})
|
|
1465
|
-
.catch(function () {
|
|
1466
|
-
return { data: [] };
|
|
1467
|
-
})
|
|
1468
|
-
])];
|
|
1302
|
+
return [4 /*yield*/, this.options.network.extras.indexerClient.getDelegationInfo(delegatedAddress)];
|
|
1469
1303
|
case 2:
|
|
1470
|
-
|
|
1471
|
-
combinedData = results[0].data.concat(results[1].data);
|
|
1472
|
-
recentTransactionData = getDataFromMostRecentTransaction(combinedData);
|
|
1304
|
+
recentTransactionData = _a.sent();
|
|
1473
1305
|
if (recentTransactionData) {
|
|
1474
1306
|
delegatedDate = recentTransactionData.date;
|
|
1475
|
-
delegatedOpLevel = recentTransactionData.
|
|
1307
|
+
delegatedOpLevel = recentTransactionData.level;
|
|
1476
1308
|
}
|
|
1477
1309
|
_a.label = 3;
|
|
1478
1310
|
case 3: return [2 /*return*/, {
|
|
@@ -1692,8 +1524,8 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1692
1524
|
case TezosOperationType_1.TezosOperationType.PROPOSALS:
|
|
1693
1525
|
case TezosOperationType_1.TezosOperationType.BALLOT:
|
|
1694
1526
|
break;
|
|
1695
|
-
default:
|
|
1696
|
-
assert_1.assertNever(operation.kind);
|
|
1527
|
+
default: // Exhaustive switch
|
|
1528
|
+
assert_1.assertNever(operation.kind);
|
|
1697
1529
|
throw new index_4.UnsupportedError(coinlib_error_1.Domain.TEZOS, "operation type not supported " + JSON.stringify(operation.kind));
|
|
1698
1530
|
}
|
|
1699
1531
|
});
|
|
@@ -1843,95 +1675,6 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1843
1675
|
}
|
|
1844
1676
|
return cycle;
|
|
1845
1677
|
};
|
|
1846
|
-
TezosProtocol.prototype.calculateRewards = function (bakerAddress, cycle, currentCycle, breakDownRewards) {
|
|
1847
|
-
if (breakDownRewards === void 0) { breakDownRewards = true; }
|
|
1848
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1849
|
-
var is005, is006, rewardCalculation;
|
|
1850
|
-
return __generator(this, function (_a) {
|
|
1851
|
-
is005 = this.options.network.extras.network === TezosNetwork.MAINNET && cycle >= TezosProtocol.FIRST_005_CYCLE;
|
|
1852
|
-
is006 = this.options.network.extras.network !== TezosNetwork.MAINNET || cycle >= TezosProtocol.FIRST_006_CYCLE;
|
|
1853
|
-
if (is006) {
|
|
1854
|
-
rewardCalculation = this.rewardCalculations.cartha;
|
|
1855
|
-
}
|
|
1856
|
-
else if (is005) {
|
|
1857
|
-
rewardCalculation = this.rewardCalculations.babylon;
|
|
1858
|
-
}
|
|
1859
|
-
else {
|
|
1860
|
-
rewardCalculation = this.rewardCalculations.alpha;
|
|
1861
|
-
}
|
|
1862
|
-
return [2 /*return*/, rewardCalculation.calculateRewards(bakerAddress, cycle, breakDownRewards, currentCycle)];
|
|
1863
|
-
});
|
|
1864
|
-
});
|
|
1865
|
-
};
|
|
1866
|
-
TezosProtocol.prototype.calculatePayouts = function (rewards, offsetOrAddresses, limit) {
|
|
1867
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1868
|
-
var delegators;
|
|
1869
|
-
return __generator(this, function (_a) {
|
|
1870
|
-
if (typeof offsetOrAddresses === 'number') {
|
|
1871
|
-
if (limit === undefined) {
|
|
1872
|
-
throw new index_4.ConditionViolationError(coinlib_error_1.Domain.TEZOS, 'limit parameter is required when providing offset');
|
|
1873
|
-
}
|
|
1874
|
-
delegators = rewards.delegatedContracts.slice(offsetOrAddresses, Math.min(offsetOrAddresses + limit, rewards.delegatedContracts.length));
|
|
1875
|
-
}
|
|
1876
|
-
else {
|
|
1877
|
-
delegators = offsetOrAddresses;
|
|
1878
|
-
}
|
|
1879
|
-
return [2 /*return*/, this.calculatePayoutForAddresses(delegators, rewards)];
|
|
1880
|
-
});
|
|
1881
|
-
});
|
|
1882
|
-
};
|
|
1883
|
-
TezosProtocol.prototype.calculatePayout = function (address, rewards) {
|
|
1884
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1885
|
-
var result;
|
|
1886
|
-
return __generator(this, function (_a) {
|
|
1887
|
-
switch (_a.label) {
|
|
1888
|
-
case 0: return [4 /*yield*/, this.calculatePayoutForAddresses([address], rewards)];
|
|
1889
|
-
case 1:
|
|
1890
|
-
result = (_a.sent()).pop();
|
|
1891
|
-
if (result === undefined) {
|
|
1892
|
-
return [2 /*return*/, {
|
|
1893
|
-
delegator: address,
|
|
1894
|
-
share: '0',
|
|
1895
|
-
payout: '0',
|
|
1896
|
-
balance: '0'
|
|
1897
|
-
}];
|
|
1898
|
-
}
|
|
1899
|
-
return [2 /*return*/, result];
|
|
1900
|
-
}
|
|
1901
|
-
});
|
|
1902
|
-
});
|
|
1903
|
-
};
|
|
1904
|
-
TezosProtocol.prototype.calculatePayoutForAddresses = function (addresses, rewards) {
|
|
1905
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1906
|
-
var result, totalRewardsBN, balances, _i, balances_1, balance, amount, share, payoutAmount;
|
|
1907
|
-
return __generator(this, function (_a) {
|
|
1908
|
-
switch (_a.label) {
|
|
1909
|
-
case 0:
|
|
1910
|
-
result = [];
|
|
1911
|
-
totalRewardsBN = new bignumber_1.default(rewards.totalRewards).plus(new bignumber_1.default(rewards.fees));
|
|
1912
|
-
return [4 /*yield*/, this.fetchBalances(addresses, rewards.snapshotBlockLevel)];
|
|
1913
|
-
case 1:
|
|
1914
|
-
balances = _a.sent();
|
|
1915
|
-
for (_i = 0, balances_1 = balances; _i < balances_1.length; _i++) {
|
|
1916
|
-
balance = balances_1[_i];
|
|
1917
|
-
amount = balance.balance;
|
|
1918
|
-
if (amount === undefined) {
|
|
1919
|
-
amount = new bignumber_1.default(0);
|
|
1920
|
-
}
|
|
1921
|
-
share = amount.div(rewards.stakingBalance);
|
|
1922
|
-
payoutAmount = totalRewardsBN.multipliedBy(share);
|
|
1923
|
-
result.push({
|
|
1924
|
-
delegator: balance.address,
|
|
1925
|
-
share: share.toFixed(),
|
|
1926
|
-
payout: payoutAmount.toFixed(),
|
|
1927
|
-
balance: amount.toFixed()
|
|
1928
|
-
});
|
|
1929
|
-
}
|
|
1930
|
-
return [2 /*return*/, result];
|
|
1931
|
-
}
|
|
1932
|
-
});
|
|
1933
|
-
});
|
|
1934
|
-
};
|
|
1935
1678
|
TezosProtocol.prototype.fetchBlockMetadata = function (block) {
|
|
1936
1679
|
return __awaiter(this, void 0, void 0, function () {
|
|
1937
1680
|
var result;
|
|
@@ -1945,41 +1688,6 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
1945
1688
|
});
|
|
1946
1689
|
});
|
|
1947
1690
|
};
|
|
1948
|
-
TezosProtocol.prototype.fetchBalances = function (addresses, blockLevel) {
|
|
1949
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1950
|
-
var body, result;
|
|
1951
|
-
return __generator(this, function (_a) {
|
|
1952
|
-
switch (_a.label) {
|
|
1953
|
-
case 0:
|
|
1954
|
-
body = {
|
|
1955
|
-
fields: ['account_id', 'balance'],
|
|
1956
|
-
predicates: [
|
|
1957
|
-
{
|
|
1958
|
-
field: 'account_id',
|
|
1959
|
-
operation: 'in',
|
|
1960
|
-
set: addresses
|
|
1961
|
-
}
|
|
1962
|
-
],
|
|
1963
|
-
snapshot: {
|
|
1964
|
-
field: 'block_level',
|
|
1965
|
-
value: blockLevel
|
|
1966
|
-
}
|
|
1967
|
-
};
|
|
1968
|
-
return [4 /*yield*/, index_1.default.post(this.options.network.extras.conseilUrl + "/v2/data/tezos/" + this.options.network.extras.conseilNetwork + "/accounts_history", body, {
|
|
1969
|
-
headers: this.headers
|
|
1970
|
-
})];
|
|
1971
|
-
case 1:
|
|
1972
|
-
result = _a.sent();
|
|
1973
|
-
return [2 /*return*/, result.data.map(function (account) {
|
|
1974
|
-
return {
|
|
1975
|
-
address: account.account_id,
|
|
1976
|
-
balance: new bignumber_1.default(account.balance)
|
|
1977
|
-
};
|
|
1978
|
-
})];
|
|
1979
|
-
}
|
|
1980
|
-
});
|
|
1981
|
-
});
|
|
1982
|
-
};
|
|
1983
1691
|
TezosProtocol.prototype.signMessage = function (message, keypair) {
|
|
1984
1692
|
return __awaiter(this, void 0, void 0, function () {
|
|
1985
1693
|
return __generator(this, function (_a) {
|
|
@@ -2024,67 +1732,19 @@ var TezosProtocol = /** @class */ (function (_super) {
|
|
|
2024
1732
|
};
|
|
2025
1733
|
TezosProtocol.prototype.getTransactionStatuses = function (transactionHashes) {
|
|
2026
1734
|
return __awaiter(this, void 0, void 0, function () {
|
|
2027
|
-
var body, result, statusGroups;
|
|
2028
1735
|
return __generator(this, function (_a) {
|
|
2029
|
-
|
|
2030
|
-
case 0:
|
|
2031
|
-
body = {
|
|
2032
|
-
fields: ['status', 'operation_group_hash'],
|
|
2033
|
-
predicates: [
|
|
2034
|
-
{
|
|
2035
|
-
field: 'operation_group_hash',
|
|
2036
|
-
operation: 'in',
|
|
2037
|
-
set: transactionHashes
|
|
2038
|
-
},
|
|
2039
|
-
{
|
|
2040
|
-
field: 'kind',
|
|
2041
|
-
operation: 'eq',
|
|
2042
|
-
set: ['transaction']
|
|
2043
|
-
}
|
|
2044
|
-
]
|
|
2045
|
-
};
|
|
2046
|
-
return [4 /*yield*/, index_1.default.post(this.options.network.extras.conseilUrl + "/v2/data/tezos/" + this.options.network.extras.conseilNetwork + "/operations", body, {
|
|
2047
|
-
headers: this.headers
|
|
2048
|
-
})];
|
|
2049
|
-
case 1:
|
|
2050
|
-
result = _a.sent();
|
|
2051
|
-
statusGroups = {};
|
|
2052
|
-
result.data.forEach(function (element) {
|
|
2053
|
-
var currentStatus = element.status === 'applied' ? IAirGapTransaction_1.AirGapTransactionStatus.APPLIED : IAirGapTransaction_1.AirGapTransactionStatus.FAILED;
|
|
2054
|
-
if (statusGroups[element.operation_group_hash] === IAirGapTransaction_1.AirGapTransactionStatus.FAILED) {
|
|
2055
|
-
// If status is "failed", we can move on because it will not change anymore
|
|
2056
|
-
return;
|
|
2057
|
-
}
|
|
2058
|
-
else if (statusGroups[element.operation_group_hash] === IAirGapTransaction_1.AirGapTransactionStatus.APPLIED) {
|
|
2059
|
-
if (currentStatus === IAirGapTransaction_1.AirGapTransactionStatus.FAILED) {
|
|
2060
|
-
// If the status so far is "applied" but the current one "failed", we need to update the status
|
|
2061
|
-
statusGroups[element.operation_group_hash] = currentStatus;
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
else {
|
|
2065
|
-
// If no status is set, use the current one
|
|
2066
|
-
statusGroups[element.operation_group_hash] = currentStatus;
|
|
2067
|
-
}
|
|
2068
|
-
});
|
|
2069
|
-
return [2 /*return*/, transactionHashes.map(function (txHash) {
|
|
2070
|
-
return statusGroups[txHash];
|
|
2071
|
-
})];
|
|
2072
|
-
}
|
|
1736
|
+
throw new Error('Method not implemented.');
|
|
2073
1737
|
});
|
|
2074
1738
|
});
|
|
2075
1739
|
};
|
|
2076
|
-
TezosProtocol.FIRST_005_CYCLE = 160;
|
|
2077
|
-
TezosProtocol.FIRST_006_CYCLE = 208;
|
|
2078
1740
|
TezosProtocol.FIRST_010_CYCLE = 388;
|
|
2079
1741
|
TezosProtocol.BLOCKS_PER_CYCLE = (_a = {},
|
|
2080
1742
|
_a[TezosNetwork.MAINNET] = [4096, 8192],
|
|
2081
|
-
_a[TezosNetwork.
|
|
2082
|
-
_a[TezosNetwork.JAKARTANET] = [4096],
|
|
1743
|
+
_a[TezosNetwork.GHOSTNET] = [4096],
|
|
2083
1744
|
_a);
|
|
2084
1745
|
TezosProtocol.TIME_BETWEEN_BLOCKS = (_b = {},
|
|
2085
1746
|
_b[TezosNetwork.MAINNET] = [60, 30],
|
|
2086
|
-
_b[TezosNetwork.
|
|
2087
|
-
_b[TezosNetwork.JAKARTANET] = [30],
|
|
1747
|
+
_b[TezosNetwork.GHOSTNET] = [30],
|
|
2088
1748
|
_b);
|
|
2089
1749
|
return TezosProtocol;
|
|
2090
1750
|
}(NonExtendedProtocol_1.NonExtendedProtocol));
|