@taquito/taquito 24.3.0-beta.2 → 24.3.0-beta.3
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/README.md +1 -1
- package/dist/lib/contract/big-map.js +6 -3
- package/dist/lib/contract/contract.js +8 -3
- package/dist/lib/contract/not-found-retry.js +29 -0
- package/dist/lib/contract/rpc-contract-provider.js +28 -18
- package/dist/lib/contract/sapling-state-abstraction.js +5 -2
- package/dist/lib/contract/semantic.js +4 -4
- package/dist/lib/estimate/rpc-estimate-provider.js +2 -0
- package/dist/lib/operations/batch-operation.js +3 -2
- package/dist/lib/operations/delegate-operation.js +3 -2
- package/dist/lib/operations/operations.js +12 -2
- package/dist/lib/operations/origination-operation.js +9 -3
- package/dist/lib/operations/register-global-constant-operation.js +3 -2
- package/dist/lib/operations/reveal-operation.js +3 -2
- package/dist/lib/operations/transaction-operation.js +4 -3
- package/dist/lib/operations/transfer-ticket-operation.js +3 -2
- package/dist/lib/prepare/prepare-provider.js +6 -5
- package/dist/lib/provider.js +82 -10
- package/dist/lib/read-provider/interface.js +8 -0
- package/dist/lib/read-provider/rpc-read-adapter.js +2 -0
- package/dist/lib/tz/interface.js +2 -0
- package/dist/lib/tz/rpc-tz-provider.js +2 -0
- package/dist/lib/version.js +2 -2
- package/dist/lib/wallet/origination-operation.js +5 -1
- package/dist/lib/wallet/receipt.js +9 -8
- package/dist/lib/wallet/wallet.js +18 -7
- package/dist/taquito.es6.js +333 -181
- package/dist/taquito.es6.js.map +1 -1
- package/dist/taquito.min.js +1 -1
- package/dist/taquito.umd.js +332 -180
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/contract/big-map.d.ts +10 -5
- package/dist/types/contract/contract.d.ts +3 -2
- package/dist/types/contract/interface.d.ts +5 -4
- package/dist/types/contract/not-found-retry.d.ts +3 -0
- package/dist/types/contract/rpc-contract-provider.d.ts +5 -4
- package/dist/types/contract/sapling-state-abstraction.d.ts +9 -4
- package/dist/types/contract/semantic.d.ts +4 -3
- package/dist/types/operations/operations.d.ts +4 -1
- package/dist/types/operations/transaction-operation.d.ts +2 -2
- package/dist/types/provider.d.ts +4 -1
- package/dist/types/read-provider/interface.d.ts +5 -1
- package/dist/types/read-provider/rpc-read-adapter.d.ts +4 -1
- package/dist/types/tz/interface.d.ts +4 -1
- package/dist/types/tz/rpc-tz-provider.d.ts +4 -1
- package/dist/types/wallet/receipt.d.ts +4 -1
- package/dist/types/wallet/wallet.d.ts +1 -0
- package/package.json +15 -17
- package/signature.json +0 -866
package/dist/lib/provider.js
CHANGED
|
@@ -8,6 +8,12 @@ const prepare_1 = require("./contract/prepare");
|
|
|
8
8
|
const rpc_1 = require("@taquito/rpc");
|
|
9
9
|
const utils_1 = require("@taquito/utils");
|
|
10
10
|
class Provider {
|
|
11
|
+
clearRpcCache() {
|
|
12
|
+
const rpc = this.context.rpc;
|
|
13
|
+
if (typeof rpc.deleteAllCachedData === 'function') {
|
|
14
|
+
rpc.deleteAllCachedData();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
11
17
|
parseRpcErrors(error) {
|
|
12
18
|
if (!(error instanceof http_utils_1.HttpResponseError)) {
|
|
13
19
|
return [];
|
|
@@ -43,7 +49,7 @@ class Provider {
|
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
|
-
|
|
52
|
+
parseCounterAdjustments(error) {
|
|
47
53
|
return this.parseRpcErrors(error)
|
|
48
54
|
.filter((value) => {
|
|
49
55
|
const id = value.id;
|
|
@@ -51,7 +57,8 @@ class Provider {
|
|
|
51
57
|
const expected = value.expected;
|
|
52
58
|
const found = value.found;
|
|
53
59
|
return (typeof id === 'string' &&
|
|
54
|
-
id.endsWith('contract.counter_in_the_past')
|
|
60
|
+
(id.endsWith('contract.counter_in_the_past') ||
|
|
61
|
+
id.endsWith('contract.counter_in_the_future')) &&
|
|
55
62
|
typeof contract === 'string' &&
|
|
56
63
|
typeof expected === 'string' &&
|
|
57
64
|
typeof found === 'string');
|
|
@@ -61,7 +68,7 @@ class Provider {
|
|
|
61
68
|
expected: BigInt(value.expected),
|
|
62
69
|
found: BigInt(value.found),
|
|
63
70
|
}))
|
|
64
|
-
.filter((value) => value.expected
|
|
71
|
+
.filter((value) => value.expected !== value.found);
|
|
65
72
|
}
|
|
66
73
|
hasGasLimitTooHighAndBlockExhausted(error) {
|
|
67
74
|
const ids = this.parseRpcErrors(error)
|
|
@@ -284,7 +291,7 @@ class Provider {
|
|
|
284
291
|
};
|
|
285
292
|
}
|
|
286
293
|
catch (error) {
|
|
287
|
-
const adjustments = this.
|
|
294
|
+
const adjustments = this.parseCounterAdjustments(error);
|
|
288
295
|
const patchedOp = this.patchSimulationCounters(op, adjustments);
|
|
289
296
|
if (patchedOp) {
|
|
290
297
|
try {
|
|
@@ -335,11 +342,21 @@ class Provider {
|
|
|
335
342
|
return opRequireReveal;
|
|
336
343
|
}
|
|
337
344
|
async signAndInject(forgedBytes) {
|
|
338
|
-
|
|
339
|
-
forgedBytes.opbytes = signed.sbytes;
|
|
340
|
-
forgedBytes.opOb.signature = signed.prefixSig;
|
|
345
|
+
let signedForgedBytes = await this.signForgedBytes(forgedBytes);
|
|
341
346
|
const opResponse = [];
|
|
342
|
-
|
|
347
|
+
let results;
|
|
348
|
+
try {
|
|
349
|
+
results = await this.rpc.preapplyOperations([signedForgedBytes.opOb]);
|
|
350
|
+
}
|
|
351
|
+
catch (error) {
|
|
352
|
+
const adjustments = this.parseCounterAdjustments(error);
|
|
353
|
+
const patchedForgedBytes = await this.patchForgedBytesCounters(signedForgedBytes, adjustments);
|
|
354
|
+
if (!patchedForgedBytes) {
|
|
355
|
+
throw error;
|
|
356
|
+
}
|
|
357
|
+
signedForgedBytes = await this.signForgedBytes(patchedForgedBytes);
|
|
358
|
+
results = await this.rpc.preapplyOperations([signedForgedBytes.opOb]);
|
|
359
|
+
}
|
|
343
360
|
if (!Array.isArray(results)) {
|
|
344
361
|
throw new errors_1.TezosPreapplyFailureError(results);
|
|
345
362
|
}
|
|
@@ -352,12 +369,67 @@ class Provider {
|
|
|
352
369
|
if (errors.length) {
|
|
353
370
|
throw new errors_1.TezosOperationError(errors, 'Error occurred during validation simulation of operation', opResponse);
|
|
354
371
|
}
|
|
372
|
+
const hash = await this.context.injector.inject(signedForgedBytes.opbytes);
|
|
373
|
+
this.clearRpcCache();
|
|
355
374
|
return {
|
|
356
|
-
hash
|
|
357
|
-
forgedBytes,
|
|
375
|
+
hash,
|
|
376
|
+
forgedBytes: signedForgedBytes,
|
|
358
377
|
opResponse,
|
|
359
378
|
context: this.context.clone(),
|
|
360
379
|
};
|
|
361
380
|
}
|
|
381
|
+
async signForgedBytes(forgedBytes) {
|
|
382
|
+
const signed = await this.signer.sign(forgedBytes.opbytes, new Uint8Array([3]));
|
|
383
|
+
return {
|
|
384
|
+
...forgedBytes,
|
|
385
|
+
opbytes: signed.sbytes,
|
|
386
|
+
opOb: {
|
|
387
|
+
...forgedBytes.opOb,
|
|
388
|
+
signature: signed.prefixSig,
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
async patchForgedBytesCounters(forgedBytes, adjustments) {
|
|
393
|
+
if (adjustments.length === 0 || !Array.isArray(forgedBytes.opOb.contents)) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const branch = forgedBytes.opOb.branch;
|
|
397
|
+
if (typeof branch !== 'string') {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const contents = forgedBytes.opOb.contents.map((content) => ({ ...content }));
|
|
401
|
+
let patched = false;
|
|
402
|
+
for (const adjustment of adjustments) {
|
|
403
|
+
const delta = adjustment.expected - adjustment.found;
|
|
404
|
+
for (const content of contents) {
|
|
405
|
+
const source = content.source;
|
|
406
|
+
const counter = content.counter;
|
|
407
|
+
if (source !== adjustment.contract || typeof counter === 'undefined') {
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
const contentCounter = BigInt(String(counter));
|
|
411
|
+
if (contentCounter < adjustment.found) {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
content.counter = (contentCounter + delta).toString();
|
|
415
|
+
patched = true;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (!patched) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
const unsignedOpBytes = await this.context.forger.forge({
|
|
422
|
+
branch,
|
|
423
|
+
contents,
|
|
424
|
+
});
|
|
425
|
+
return {
|
|
426
|
+
...forgedBytes,
|
|
427
|
+
opbytes: unsignedOpBytes,
|
|
428
|
+
opOb: {
|
|
429
|
+
...forgedBytes.opOb,
|
|
430
|
+
contents,
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
}
|
|
362
434
|
}
|
|
363
435
|
exports.Provider = Provider;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBlockHashIdentifier = void 0;
|
|
4
|
+
const utils_1 = require("@taquito/utils");
|
|
5
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
6
|
+
const BigNumber = bignumber_js_1.default;
|
|
7
|
+
const isBlockHashIdentifier = (block) => {
|
|
8
|
+
return (0, utils_1.validateBlock)(block) === utils_1.ValidationResult.VALID;
|
|
9
|
+
};
|
|
10
|
+
exports.isBlockHashIdentifier = isBlockHashIdentifier;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RpcReadAdapter = void 0;
|
|
4
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
5
|
+
const BigNumber = bignumber_js_1.default;
|
|
4
6
|
/**
|
|
5
7
|
* Converts calls from TzReadProvider into calls to the wrapped RpcClient in a format it can understand.
|
|
6
8
|
*/
|
package/dist/lib/tz/interface.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RpcTzProvider = void 0;
|
|
4
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
5
|
+
const BigNumber = bignumber_js_1.default;
|
|
4
6
|
const operations_1 = require("../operations/operations");
|
|
5
7
|
const utils_1 = require("@taquito/utils");
|
|
6
8
|
const core_1 = require("@taquito/core");
|
package/dist/lib/version.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "24.3.0-beta.
|
|
6
|
+
"commitHash": "a312cd3f4fc0ab0fb3351bfffe6ad855772cb077",
|
|
7
|
+
"version": "24.3.0-beta.3"
|
|
8
8
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OriginationWalletOperation = void 0;
|
|
4
4
|
const rpc_1 = require("@taquito/rpc");
|
|
5
|
+
const interface_1 = require("../read-provider/interface");
|
|
5
6
|
const types_1 = require("../operations/types");
|
|
6
7
|
const operation_1 = require("./operation");
|
|
7
8
|
const errors_1 = require("./errors");
|
|
@@ -47,7 +48,10 @@ class OriginationWalletOperation extends operation_1.WalletOperation {
|
|
|
47
48
|
}
|
|
48
49
|
await this.confirmation();
|
|
49
50
|
const inclusionBlock = await this.getInclusionBlock();
|
|
50
|
-
|
|
51
|
+
if (!(0, interface_1.isBlockHashIdentifier)(inclusionBlock.hash)) {
|
|
52
|
+
throw new errors_1.OriginationWalletOperationError('Inclusion block hash is invalid');
|
|
53
|
+
}
|
|
54
|
+
return this.context.wallet.at(address, undefined, inclusionBlock.hash);
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
exports.OriginationWalletOperation = OriginationWalletOperation;
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.receiptFromOperation = void 0;
|
|
4
4
|
const bignumber_js_1 = require("bignumber.js");
|
|
5
|
+
const BigNumber = bignumber_js_1.default;
|
|
5
6
|
const constants_1 = require("../constants");
|
|
6
7
|
const errors_1 = require("../operations/errors");
|
|
7
8
|
const receiptFromOperation = (op, { ALLOCATION_BURN, ORIGINATION_BURN } = {
|
|
8
9
|
ALLOCATION_BURN: 257,
|
|
9
10
|
ORIGINATION_BURN: 257,
|
|
10
11
|
}) => {
|
|
11
|
-
|
|
12
|
+
BigNumber.config({ DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_UP });
|
|
12
13
|
const operationResults = (0, errors_1.flattenOperationResult)({ contents: op });
|
|
13
|
-
let totalMilliGas = new
|
|
14
|
-
let totalStorage = new
|
|
15
|
-
let totalFee = new
|
|
16
|
-
let totalOriginationBurn = new
|
|
17
|
-
let totalAllocationBurn = new
|
|
18
|
-
let totalPaidStorageDiff = new
|
|
14
|
+
let totalMilliGas = new BigNumber(0);
|
|
15
|
+
let totalStorage = new BigNumber(0);
|
|
16
|
+
let totalFee = new BigNumber(0);
|
|
17
|
+
let totalOriginationBurn = new BigNumber(0);
|
|
18
|
+
let totalAllocationBurn = new BigNumber(0);
|
|
19
|
+
let totalPaidStorageDiff = new BigNumber(0);
|
|
19
20
|
operationResults.forEach((result) => {
|
|
20
21
|
totalFee = totalFee.plus(result.fee || 0);
|
|
21
22
|
totalOriginationBurn = totalOriginationBurn.plus(Array.isArray(result.originated_contracts)
|
|
@@ -37,7 +38,7 @@ const receiptFromOperation = (op, { ALLOCATION_BURN, ORIGINATION_BURN } = {
|
|
|
37
38
|
totalAllocationBurn,
|
|
38
39
|
totalOriginationBurn,
|
|
39
40
|
totalPaidStorageDiff,
|
|
40
|
-
totalStorageBurn: new
|
|
41
|
+
totalStorageBurn: new BigNumber(totalStorage.multipliedBy(constants_1.COST_PER_BYTE)),
|
|
41
42
|
};
|
|
42
43
|
};
|
|
43
44
|
exports.receiptFromOperation = receiptFromOperation;
|
|
@@ -4,8 +4,8 @@ exports.Wallet = exports.WalletOperationBatch = void 0;
|
|
|
4
4
|
const contract_1 = require("../contract/contract");
|
|
5
5
|
const types_1 = require("../operations/types");
|
|
6
6
|
const core_1 = require("@taquito/core");
|
|
7
|
-
const http_utils_1 = require("@taquito/http-utils");
|
|
8
7
|
const utils_1 = require("@taquito/utils");
|
|
8
|
+
const not_found_retry_1 = require("../contract/not-found-retry");
|
|
9
9
|
class WalletOperationBatch {
|
|
10
10
|
constructor(walletProvider, context) {
|
|
11
11
|
this.walletProvider = walletProvider;
|
|
@@ -428,17 +428,28 @@ class Wallet {
|
|
|
428
428
|
// Newly originated contracts can be visible at the operation's inclusion level in one RPC
|
|
429
429
|
// call and still lag on another endpoint of the same rolling node. Retry at head so
|
|
430
430
|
// wallet op.contract() behaves like octez-client, which resolves the originated contract
|
|
431
|
-
// after confirmation instead of pinning itself to a stale context forever.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
contractState = await loadContractState('head');
|
|
431
|
+
// after confirmation instead of pinning itself to a stale context forever. The head index
|
|
432
|
+
// can lag briefly as well, so bound a few retries there too.
|
|
433
|
+
if (block !== 'head' && (0, not_found_retry_1.isNotFoundError)(error)) {
|
|
434
|
+
contractState = await (0, not_found_retry_1.retryOnNotFound)(() => loadContractState('head'));
|
|
436
435
|
}
|
|
437
436
|
else {
|
|
438
437
|
throw error;
|
|
439
438
|
}
|
|
440
439
|
}
|
|
441
|
-
const abs = new contract_1.ContractAbstraction(address, contractState.script, this, this.context.contract, contractState.entrypoints, rpc, readProvider);
|
|
440
|
+
const abs = new contract_1.ContractAbstraction(address, contractState.script, this, this.context.contract, contractState.entrypoints, rpc, readProvider, 'head');
|
|
441
|
+
return contractAbstractionComposer(abs, this.context);
|
|
442
|
+
}
|
|
443
|
+
async atExactBlock(address, contractAbstractionComposer = (x) => x, block) {
|
|
444
|
+
const addressValidation = (0, utils_1.validateContractAddress)(address);
|
|
445
|
+
if (addressValidation !== utils_1.ValidationResult.VALID) {
|
|
446
|
+
throw new core_1.InvalidContractAddressError(address, addressValidation);
|
|
447
|
+
}
|
|
448
|
+
const rpc = this.context.withExtensions().rpc;
|
|
449
|
+
const readProvider = this.context.withExtensions().readProvider;
|
|
450
|
+
const script = await readProvider.getScript(address, block);
|
|
451
|
+
const entrypoints = await rpc.getEntrypoints(address, { block: String(block) });
|
|
452
|
+
const abs = new contract_1.ContractAbstraction(address, script, this, this.context.contract, entrypoints, rpc, readProvider, block);
|
|
442
453
|
return contractAbstractionComposer(abs, this.context);
|
|
443
454
|
}
|
|
444
455
|
}
|