@taquito/taquito 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.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/batch/rpc-batch-provider.js +91 -83
  3. package/dist/lib/context.js +22 -26
  4. package/dist/lib/contract/big-map.js +16 -29
  5. package/dist/lib/contract/contract-methods/contract-method-object-param.js +7 -7
  6. package/dist/lib/contract/contract-methods/contract-on-chain-view.js +31 -44
  7. package/dist/lib/contract/contract.js +21 -32
  8. package/dist/lib/contract/errors.js +9 -9
  9. package/dist/lib/contract/prepare.js +36 -45
  10. package/dist/lib/contract/rpc-contract-provider.js +426 -475
  11. package/dist/lib/contract/sapling-state-abstraction.js +3 -14
  12. package/dist/lib/contract/semantic.js +2 -2
  13. package/dist/lib/errors.js +3 -3
  14. package/dist/lib/estimate/errors.js +1 -1
  15. package/dist/lib/estimate/estimate.js +66 -20
  16. package/dist/lib/estimate/rpc-estimate-provider.js +427 -460
  17. package/dist/lib/forger/composite-forger.js +16 -27
  18. package/dist/lib/forger/errors.js +2 -2
  19. package/dist/lib/forger/taquito-local-forger.js +9 -22
  20. package/dist/lib/global-constants/default-global-constants-provider.js +8 -19
  21. package/dist/lib/global-constants/errors.js +2 -2
  22. package/dist/lib/global-constants/noop-global-constants-provider.js +2 -13
  23. package/dist/lib/import-key.js +23 -34
  24. package/dist/lib/injector/rpc-injector.js +13 -24
  25. package/dist/lib/operations/ballot-operation.js +2 -3
  26. package/dist/lib/operations/delegate-operation.js +5 -8
  27. package/dist/lib/operations/drain-delegate-operation.js +1 -1
  28. package/dist/lib/operations/errors.js +9 -6
  29. package/dist/lib/operations/increase-paid-storage-operation.js +4 -7
  30. package/dist/lib/operations/operations.js +100 -30
  31. package/dist/lib/operations/origination-operation.js +16 -27
  32. package/dist/lib/operations/proposals-operation.js +2 -3
  33. package/dist/lib/operations/register-global-constant-operation.js +4 -7
  34. package/dist/lib/operations/reveal-operation.js +1 -1
  35. package/dist/lib/operations/smart-rollup-add-messages-operation.js +4 -7
  36. package/dist/lib/operations/smart-rollup-execute-outbox-message-operation.js +4 -7
  37. package/dist/lib/operations/smart-rollup-originate-operation.js +4 -7
  38. package/dist/lib/operations/transaction-operation.js +2 -2
  39. package/dist/lib/operations/transfer-ticket-operation.js +4 -6
  40. package/dist/lib/operations/types.js +17 -19
  41. package/dist/lib/operations/update-companion-key-operation.js +4 -7
  42. package/dist/lib/operations/update-consensus-key-operation.js +4 -7
  43. package/dist/lib/packer/michel-codec-packer.js +3 -14
  44. package/dist/lib/packer/rpc-packer.js +2 -13
  45. package/dist/lib/parser/michel-codec-parser.js +82 -107
  46. package/dist/lib/parser/noop-parser.js +2 -13
  47. package/dist/lib/prepare/prepare-provider.js +780 -744
  48. package/dist/lib/provider.js +322 -128
  49. package/dist/lib/read-provider/rpc-read-adapter.js +76 -121
  50. package/dist/lib/signer/errors.js +1 -1
  51. package/dist/lib/signer/noop.js +9 -26
  52. package/dist/lib/subscribe/errors.js +2 -2
  53. package/dist/lib/subscribe/polling-subcribe-provider.js +35 -38
  54. package/dist/lib/taquito.js +33 -33
  55. package/dist/lib/tz/rpc-tz-provider.js +27 -44
  56. package/dist/lib/version.js +2 -2
  57. package/dist/lib/wallet/batch-operation.js +32 -45
  58. package/dist/lib/wallet/delegation-operation.js +25 -40
  59. package/dist/lib/wallet/errors.js +15 -3
  60. package/dist/lib/wallet/increase-paid-storage-operation.js +25 -40
  61. package/dist/lib/wallet/legacy.js +28 -63
  62. package/dist/lib/wallet/operation-factory.js +27 -56
  63. package/dist/lib/wallet/operation.js +123 -59
  64. package/dist/lib/wallet/origination-operation.js +34 -46
  65. package/dist/lib/wallet/register-global-constant-operation.js +26 -43
  66. package/dist/lib/wallet/transaction-operation.js +21 -36
  67. package/dist/lib/wallet/transfer-ticket-operation.js +21 -36
  68. package/dist/lib/wallet/wallet.js +187 -184
  69. package/dist/taquito.es6.js +3424 -3197
  70. package/dist/taquito.es6.js.map +1 -1
  71. package/dist/taquito.min.js +1 -1
  72. package/dist/taquito.umd.js +7930 -7701
  73. package/dist/taquito.umd.js.map +1 -1
  74. package/dist/types/batch/rpc-batch-provider.d.ts +18 -18
  75. package/dist/types/context.d.ts +4 -4
  76. package/dist/types/contract/big-map.d.ts +3 -3
  77. package/dist/types/contract/contract-methods/contract-method-interface.d.ts +4 -4
  78. package/dist/types/contract/contract-methods/contract-method-object-param.d.ts +6 -6
  79. package/dist/types/contract/contract-methods/contract-on-chain-view.d.ts +3 -3
  80. package/dist/types/contract/contract.d.ts +6 -6
  81. package/dist/types/contract/errors.d.ts +11 -11
  82. package/dist/types/contract/interface.d.ts +42 -42
  83. package/dist/types/contract/rpc-contract-provider.d.ts +44 -43
  84. package/dist/types/contract/sapling-state-abstraction.d.ts +1 -1
  85. package/dist/types/contract/semantic.d.ts +2 -2
  86. package/dist/types/errors.d.ts +5 -5
  87. package/dist/types/estimate/errors.d.ts +1 -1
  88. package/dist/types/estimate/estimate-provider-interface.d.ts +81 -84
  89. package/dist/types/estimate/estimate.d.ts +28 -11
  90. package/dist/types/estimate/rpc-estimate-provider.d.ts +34 -30
  91. package/dist/types/forger/errors.d.ts +2 -2
  92. package/dist/types/global-constants/default-global-constants-provider.d.ts +2 -2
  93. package/dist/types/global-constants/errors.d.ts +2 -2
  94. package/dist/types/global-constants/interface-global-constants-provider.d.ts +1 -1
  95. package/dist/types/import-key.d.ts +2 -2
  96. package/dist/types/operations/ballot-operation.d.ts +1 -1
  97. package/dist/types/operations/delegate-operation.d.ts +2 -2
  98. package/dist/types/operations/drain-delegate-operation.d.ts +1 -1
  99. package/dist/types/operations/errors.d.ts +5 -5
  100. package/dist/types/operations/failing-noop-operation.d.ts +1 -1
  101. package/dist/types/operations/increase-paid-storage-operation.d.ts +1 -1
  102. package/dist/types/operations/operations.d.ts +2 -2
  103. package/dist/types/operations/origination-operation.d.ts +5 -5
  104. package/dist/types/operations/proposals-operation.d.ts +1 -1
  105. package/dist/types/operations/register-global-constant-operation.d.ts +2 -2
  106. package/dist/types/operations/reveal-operation.d.ts +1 -1
  107. package/dist/types/operations/smart-rollup-add-messages-operation.d.ts +1 -1
  108. package/dist/types/operations/smart-rollup-execute-outbox-message-operation.d.ts +1 -1
  109. package/dist/types/operations/smart-rollup-originate-operation.d.ts +1 -1
  110. package/dist/types/operations/transaction-operation.d.ts +2 -2
  111. package/dist/types/operations/transfer-ticket-operation.d.ts +2 -2
  112. package/dist/types/operations/types.d.ts +387 -25
  113. package/dist/types/operations/update-companion-key-operation.d.ts +1 -1
  114. package/dist/types/operations/update-consensus-key-operation.d.ts +1 -1
  115. package/dist/types/prepare/interface.d.ts +32 -33
  116. package/dist/types/prepare/prepare-provider.d.ts +34 -60
  117. package/dist/types/provider.d.ts +7 -1
  118. package/dist/types/read-provider/interface.d.ts +21 -21
  119. package/dist/types/read-provider/rpc-read-adapter.d.ts +22 -22
  120. package/dist/types/signer/errors.d.ts +1 -1
  121. package/dist/types/signer/noop.d.ts +1 -1
  122. package/dist/types/subscribe/errors.d.ts +2 -2
  123. package/dist/types/taquito.d.ts +33 -33
  124. package/dist/types/wallet/errors.d.ts +10 -2
  125. package/dist/types/wallet/interface.d.ts +13 -13
  126. package/dist/types/wallet/operation.d.ts +4 -3
  127. package/dist/types/wallet/wallet.d.ts +36 -35
  128. package/package.json +27 -15
  129. package/LICENSE +0 -202
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.LegacyWalletProvider = void 0;
13
4
  const types_1 = require("../operations/types");
@@ -15,72 +6,46 @@ class LegacyWalletProvider {
15
6
  constructor(context) {
16
7
  this.context = context;
17
8
  }
18
- getPKH() {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- return this.context.signer.publicKeyHash();
21
- });
9
+ async getPKH() {
10
+ return this.context.signer.publicKeyHash();
22
11
  }
23
- getPK() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- return this.context.signer.publicKey();
26
- });
12
+ async getPK() {
13
+ return this.context.signer.publicKey();
27
14
  }
28
- mapTransferParamsToWalletParams(params) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSACTION);
31
- });
15
+ async mapTransferParamsToWalletParams(params) {
16
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.TRANSACTION);
32
17
  }
33
- mapStakeParamsToWalletParams(params) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSACTION);
36
- });
18
+ async mapStakeParamsToWalletParams(params) {
19
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.TRANSACTION);
37
20
  }
38
- mapUnstakeParamsToWalletParams(params) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSACTION);
41
- });
21
+ async mapUnstakeParamsToWalletParams(params) {
22
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.TRANSACTION);
42
23
  }
43
- mapFinalizeUnstakeParamsToWalletParams(params) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSACTION);
46
- });
24
+ async mapFinalizeUnstakeParamsToWalletParams(params) {
25
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.TRANSACTION);
47
26
  }
48
- mapOriginateParamsToWalletParams(params) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.ORIGINATION);
51
- });
27
+ async mapOriginateParamsToWalletParams(params) {
28
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.ORIGINATION);
52
29
  }
53
- mapDelegateParamsToWalletParams(params) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.DELEGATION);
56
- });
30
+ async mapDelegateParamsToWalletParams(params) {
31
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.DELEGATION);
57
32
  }
58
- mapIncreasePaidStorageWalletParams(params) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.INCREASE_PAID_STORAGE);
61
- });
33
+ async mapIncreasePaidStorageWalletParams(params) {
34
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.INCREASE_PAID_STORAGE);
62
35
  }
63
- mapTransferTicketParamsToWalletParams(params) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.TRANSFER_TICKET);
66
- });
36
+ async mapTransferTicketParamsToWalletParams(params) {
37
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.TRANSFER_TICKET);
67
38
  }
68
- mapRegisterGlobalConstantParamsToWalletParams(params) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- return (0, types_1.attachKind)(yield params(), types_1.OpKind.REGISTER_GLOBAL_CONSTANT);
71
- });
39
+ async mapRegisterGlobalConstantParamsToWalletParams(params) {
40
+ return (0, types_1.attachKind)(await params(), types_1.OpKind.REGISTER_GLOBAL_CONSTANT);
72
41
  }
73
- sendOperations(params) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const op = yield this.context.batch.batch(params).send();
76
- return op.hash;
77
- });
42
+ async sendOperations(params) {
43
+ const op = await this.context.batch.batch(params).send();
44
+ return op.hash;
78
45
  }
79
- sign(bytes, watermark) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const { prefixSig } = yield this.context.signer.sign(bytes, watermark);
82
- return prefixSig;
83
- });
46
+ async sign(bytes, watermark) {
47
+ const { prefixSig } = await this.context.signer.sign(bytes, watermark);
48
+ return prefixSig;
84
49
  }
85
50
  }
86
51
  exports.LegacyWalletProvider = LegacyWalletProvider;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.OperationFactory = exports.createNewPollingBasedHeadObservable = void 0;
13
4
  exports.timeoutAfter = timeoutAfter;
@@ -48,70 +39,50 @@ class OperationFactory {
48
39
  return (0, create_observable_from_subscription_1.createObservableFromSubscription)(this.context.stream.subscribeBlock('head'));
49
40
  });
50
41
  }
51
- createNewHeadObservable() {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- return (0, exports.createNewPollingBasedHeadObservable)(this.sharedHeadObs, this.context);
54
- });
42
+ async createNewHeadObservable() {
43
+ return (0, exports.createNewPollingBasedHeadObservable)(this.sharedHeadObs, this.context);
55
44
  }
56
45
  createPastBlockWalker(startBlock, count = 1) {
57
46
  return (0, rxjs_1.from)(this.context.readProvider.getBlock(startBlock)).pipe((0, operators_1.switchMap)((block) => {
58
47
  if (count === 1) {
59
48
  return (0, rxjs_1.of)(block);
60
49
  }
61
- return (0, rxjs_1.range)(block.header.level, count - 1).pipe((0, operators_1.startWith)(block), (0, operators_1.concatMap)((level) => __awaiter(this, void 0, void 0, function* () {
50
+ return (0, rxjs_1.range)(block.header.level, count - 1).pipe((0, operators_1.startWith)(block), (0, operators_1.concatMap)(async (level) => {
62
51
  return this.context.readProvider.getBlock(typeof level === 'number' ? level : level.header.level);
63
- })));
52
+ }));
64
53
  }));
65
54
  }
66
- createHeadObservableFromConfig(_a) {
67
- return __awaiter(this, arguments, void 0, function* ({ blockIdentifier }) {
68
- const observableSequence = [];
69
- if (blockIdentifier) {
70
- observableSequence.push(this.createPastBlockWalker(blockIdentifier));
71
- }
72
- observableSequence.push(yield this.createNewHeadObservable());
73
- return (0, rxjs_1.concat)(...observableSequence);
74
- });
55
+ async createHeadObservableFromConfig({ blockIdentifier }) {
56
+ const observableSequence = [];
57
+ if (blockIdentifier) {
58
+ observableSequence.push(this.createPastBlockWalker(blockIdentifier));
59
+ }
60
+ observableSequence.push(await this.createNewHeadObservable());
61
+ return (0, rxjs_1.concat)(...observableSequence);
75
62
  }
76
- createOperation(hash_1) {
77
- return __awaiter(this, arguments, void 0, function* (hash, config = {}) {
78
- return new operation_1.WalletOperation(hash, this.context.clone(), yield this.createHeadObservableFromConfig(config));
79
- });
63
+ async createOperation(hash, config = {}) {
64
+ return new operation_1.WalletOperation(hash, this.context.clone(), await this.createHeadObservableFromConfig(config));
80
65
  }
81
- createBatchOperation(hash_1) {
82
- return __awaiter(this, arguments, void 0, function* (hash, config = {}) {
83
- return new batch_operation_1.BatchWalletOperation(hash, this.context.clone(), yield this.createHeadObservableFromConfig(config));
84
- });
66
+ async createBatchOperation(hash, config = {}) {
67
+ return new batch_operation_1.BatchWalletOperation(hash, this.context.clone(), await this.createHeadObservableFromConfig(config));
85
68
  }
86
- createTransactionOperation(hash_1) {
87
- return __awaiter(this, arguments, void 0, function* (hash, config = {}) {
88
- return new transaction_operation_1.TransactionWalletOperation(hash, this.context.clone(), yield this.createHeadObservableFromConfig(config));
89
- });
69
+ async createTransactionOperation(hash, config = {}) {
70
+ return new transaction_operation_1.TransactionWalletOperation(hash, this.context.clone(), await this.createHeadObservableFromConfig(config));
90
71
  }
91
- createTransferTicketOperation(hash_1) {
92
- return __awaiter(this, arguments, void 0, function* (hash, config = {}) {
93
- return new transfer_ticket_operation_1.TransferTicketWalletOperation(hash, this.context.clone(), yield this.createHeadObservableFromConfig(config));
94
- });
72
+ async createTransferTicketOperation(hash, config = {}) {
73
+ return new transfer_ticket_operation_1.TransferTicketWalletOperation(hash, this.context.clone(), await this.createHeadObservableFromConfig(config));
95
74
  }
96
- createDelegationOperation(hash_1) {
97
- return __awaiter(this, arguments, void 0, function* (hash, config = {}) {
98
- return new delegation_operation_1.DelegationWalletOperation(hash, this.context.clone(), yield this.createHeadObservableFromConfig(config));
99
- });
75
+ async createDelegationOperation(hash, config = {}) {
76
+ return new delegation_operation_1.DelegationWalletOperation(hash, this.context.clone(), await this.createHeadObservableFromConfig(config));
100
77
  }
101
- createOriginationOperation(hash_1) {
102
- return __awaiter(this, arguments, void 0, function* (hash, config = {}) {
103
- return new origination_operation_1.OriginationWalletOperation(hash, this.context.clone(), yield this.createHeadObservableFromConfig(config));
104
- });
78
+ async createOriginationOperation(hash, config = {}) {
79
+ return new origination_operation_1.OriginationWalletOperation(hash, this.context.clone(), await this.createHeadObservableFromConfig(config));
105
80
  }
106
- createIncreasePaidStorageOperation(hash_1) {
107
- return __awaiter(this, arguments, void 0, function* (hash, config = {}) {
108
- return new increase_paid_storage_operation_1.IncreasePaidStorageWalletOperation(hash, this.context.clone(), yield this.createHeadObservableFromConfig(config));
109
- });
81
+ async createIncreasePaidStorageOperation(hash, config = {}) {
82
+ return new increase_paid_storage_operation_1.IncreasePaidStorageWalletOperation(hash, this.context.clone(), await this.createHeadObservableFromConfig(config));
110
83
  }
111
- createRegisterGlobalConstantOperation(hash_1) {
112
- return __awaiter(this, arguments, void 0, function* (hash, config = {}) {
113
- return new register_global_constant_operation_1.RegisterGlobalConstantWalletOperation(hash, this.context.clone(), yield this.createHeadObservableFromConfig(config));
114
- });
84
+ async createRegisterGlobalConstantOperation(hash, config = {}) {
85
+ return new register_global_constant_operation_1.RegisterGlobalConstantWalletOperation(hash, this.context.clone(), await this.createHeadObservableFromConfig(config));
115
86
  }
116
87
  }
117
88
  exports.OperationFactory = OperationFactory;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.WalletOperation = void 0;
13
4
  const rxjs_1 = require("rxjs");
@@ -18,32 +9,76 @@ const errors_1 = require("../errors");
18
9
  const errors_2 = require("./errors");
19
10
  const core_1 = require("@taquito/core");
20
11
  const MAX_BRANCH_ANCESTORS = 60;
12
+ const walletOpTraceEnabled = /^(1|true)$/i.test(process?.env?.TAQUITO_OP_TRACE ?? '');
13
+ const walletOpTraceVerbose = /^(1|true)$/i.test(process?.env?.TAQUITO_OP_TRACE_VERBOSE ?? '');
14
+ const parsedWalletOpTraceSlowMs = Number(process?.env?.TAQUITO_OP_TRACE_SLOW_MS ?? '60000');
15
+ const walletOpTraceSlowMs = Number.isFinite(parsedWalletOpTraceSlowMs) && parsedWalletOpTraceSlowMs >= 0
16
+ ? parsedWalletOpTraceSlowMs
17
+ : 60000;
18
+ const asRecord = (value) => typeof value === 'object' && value !== null ? value : undefined;
19
+ const getErrors = (value) => (Array.isArray(value) ? value : []);
20
+ const summarizeWalletOperationResults = (results) => Array.isArray(results)
21
+ ? results.map((result) => {
22
+ const resultRecord = asRecord(result) ?? {};
23
+ const metadata = asRecord(resultRecord.metadata);
24
+ const operationResult = asRecord(metadata?.operation_result);
25
+ return {
26
+ kind: typeof resultRecord.kind === 'string' ? resultRecord.kind : 'unknown',
27
+ status: typeof operationResult?.status === 'string' ? operationResult.status : 'unknown',
28
+ errors: getErrors(operationResult?.errors),
29
+ consumed_milligas: typeof operationResult?.consumed_milligas === 'string'
30
+ ? operationResult.consumed_milligas
31
+ : undefined,
32
+ };
33
+ })
34
+ : [];
35
+ const toErrorMessage = (error) => {
36
+ if (error instanceof Error) {
37
+ return `${error.name}: ${error.message}`;
38
+ }
39
+ return String(error);
40
+ };
41
+ const traceWalletOperation = (payload) => {
42
+ if (!walletOpTraceEnabled) {
43
+ return;
44
+ }
45
+ // JSON logs are easier to aggregate when diagnosing flaky CI behavior.
46
+ console.log(`[taquito:wallet-op-trace] ${JSON.stringify(payload)}`);
47
+ };
21
48
  /**
22
- * @description WalletOperation allows to monitor operation inclusion on chains and surface information related to the operation
49
+ * WalletOperation allows to monitor operation inclusion on chains and surface information related to the operation
23
50
  */
24
51
  class WalletOperation {
25
- operationResults() {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- return this._operationResult.pipe((0, operators_1.first)()).toPromise();
28
- });
52
+ async operationResults() {
53
+ return this._operationResult.pipe((0, operators_1.first)()).toPromise();
54
+ }
55
+ async getInclusionBlock() {
56
+ const inclusionBlock = await this._includedInBlock.pipe((0, operators_1.first)()).toPromise();
57
+ if (!inclusionBlock) {
58
+ throw new errors_2.ObservableError('Inclusion block is undefined');
59
+ }
60
+ return inclusionBlock;
61
+ }
62
+ async getOperationResultsIfIncluded() {
63
+ if (!this._included) {
64
+ return undefined;
65
+ }
66
+ return this.operationResults().catch(() => undefined);
29
67
  }
30
68
  /**
31
- * @description Receipt expose the total amount of tezos token burn and spent on fees
69
+ * Receipt expose the total amount of tezos token burn and spent on fees
32
70
  * The promise returned by receipt will resolve only once the transaction is included
33
71
  */
34
- receipt() {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const results = yield this.operationResults();
37
- if (!results) {
38
- throw new errors_2.ObservableError('Unable to get operation results');
39
- }
40
- return (0, receipt_1.receiptFromOperation)(results);
41
- });
72
+ async receipt() {
73
+ const results = await this.operationResults();
74
+ if (!results) {
75
+ throw new errors_2.ObservableError('Unable to get operation results');
76
+ }
77
+ return (0, receipt_1.receiptFromOperation)(results);
42
78
  }
43
79
  /**
44
80
  *
45
81
  * @param opHash Operation hash
46
- * @param raw Raw operation that was injected
47
82
  * @param context Taquito context allowing access to rpc and signer
48
83
  * @throws {InvalidOperationHashError}
49
84
  */
@@ -55,8 +90,7 @@ class WalletOperation {
55
90
  this._includedInBlock = new rxjs_1.ReplaySubject(1);
56
91
  this._included = false;
57
92
  this.newHead$ = this._newHead$.pipe((0, operators_1.switchMap)((newHead) => {
58
- var _a, _b;
59
- const prevHead = (_b = (_a = this.lastHead) === null || _a === void 0 ? void 0 : _a.header.level) !== null && _b !== void 0 ? _b : newHead.header.level - 1;
93
+ const prevHead = this.lastHead?.header.level ?? newHead.header.level - 1;
60
94
  return (0, rxjs_1.range)(prevHead + 1, newHead.header.level - prevHead - 1).pipe((0, operators_1.concatMap)((level) => this.context.readProvider.getBlock(level)), (0, operators_1.endWith)(newHead));
61
95
  }), (0, operators_1.tap)((newHead) => (this.lastHead = newHead)), (0, operators_1.share)({
62
96
  connector: () => new rxjs_1.ReplaySubject(1),
@@ -92,38 +126,31 @@ class WalletOperation {
92
126
  .pipe((0, operators_1.first)(), (0, operators_1.catchError)(() => (0, rxjs_1.of)(undefined)))
93
127
  .subscribe();
94
128
  }
95
- getCurrentConfirmation() {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- if (!this._included) {
98
- return 0;
99
- }
100
- return (0, rxjs_1.combineLatest)([this._includedInBlock, (0, rxjs_1.from)(this.context.readProvider.getBlock('head'))])
101
- .pipe((0, operators_1.map)(([foundAtBlock, head]) => {
102
- return head.header.level - foundAtBlock.header.level + 1;
103
- }), (0, operators_1.first)())
104
- .toPromise();
105
- });
129
+ async getCurrentConfirmation() {
130
+ if (!this._included) {
131
+ return 0;
132
+ }
133
+ return (0, rxjs_1.combineLatest)([this._includedInBlock, (0, rxjs_1.from)(this.context.readProvider.getBlock('head'))])
134
+ .pipe((0, operators_1.map)(([foundAtBlock, head]) => {
135
+ return head.header.level - foundAtBlock.header.level + 1;
136
+ }), (0, operators_1.first)())
137
+ .toPromise();
106
138
  }
107
- isInCurrentBranch() {
108
- return __awaiter(this, arguments, void 0, function* (tipBlockIdentifier = 'head') {
109
- // By default it is assumed that the operation is in the current branch
110
- if (!this._included) {
111
- return true;
112
- }
113
- const tipBlockHeaderLevel = yield this.context.readProvider.getBlockLevel(tipBlockIdentifier);
114
- const inclusionBlock = yield this._includedInBlock.pipe((0, operators_1.first)()).toPromise();
115
- if (!inclusionBlock) {
116
- throw new errors_2.ObservableError('Inclusion block is undefined');
117
- }
118
- const levelDiff = (tipBlockHeaderLevel - inclusionBlock.header.level);
119
- // Block produced before the operation is included are assumed to be part of the current branch
120
- if (levelDiff <= 0) {
121
- return true;
122
- }
123
- const tipBlockLevel = Math.min(inclusionBlock.header.level + levelDiff, inclusionBlock.header.level + MAX_BRANCH_ANCESTORS);
124
- const blocks = new Set(yield this.context.readProvider.getLiveBlocks(tipBlockLevel));
125
- return blocks.has(inclusionBlock.hash);
126
- });
139
+ async isInCurrentBranch(tipBlockIdentifier = 'head') {
140
+ // By default it is assumed that the operation is in the current branch
141
+ if (!this._included) {
142
+ return true;
143
+ }
144
+ const tipBlockHeaderLevel = await this.context.readProvider.getBlockLevel(tipBlockIdentifier);
145
+ const inclusionBlock = await this.getInclusionBlock();
146
+ const levelDiff = (tipBlockHeaderLevel - inclusionBlock.header.level);
147
+ // Block produced before the operation is included are assumed to be part of the current branch
148
+ if (levelDiff <= 0) {
149
+ return true;
150
+ }
151
+ const tipBlockLevel = Math.min(inclusionBlock.header.level + levelDiff, inclusionBlock.header.level + MAX_BRANCH_ANCESTORS);
152
+ const blocks = new Set(await this.context.readProvider.getLiveBlocks(tipBlockLevel));
153
+ return blocks.has(inclusionBlock.hash);
127
154
  }
128
155
  confirmationObservable(confirmations) {
129
156
  if (typeof confirmations !== 'undefined' && confirmations < 1) {
@@ -150,8 +177,45 @@ class WalletOperation {
150
177
  *
151
178
  * @param confirmations [0] Number of confirmation to wait for
152
179
  */
153
- confirmation(confirmations) {
154
- return this.confirmationObservable(confirmations).toPromise();
180
+ async confirmation(confirmations) {
181
+ const startedAt = Date.now();
182
+ const expectedConfirmation = confirmations ?? this.context.config.defaultConfirmationCount;
183
+ try {
184
+ const confirmationResult = await this.confirmationObservable(confirmations).toPromise();
185
+ const operationResults = await this.getOperationResultsIfIncluded();
186
+ const summary = summarizeWalletOperationResults(operationResults);
187
+ const nonAppliedStatuses = summary
188
+ .filter((result) => result.status !== 'applied')
189
+ .map((result) => result.status);
190
+ const elapsedMs = Date.now() - startedAt;
191
+ if (walletOpTraceVerbose ||
192
+ elapsedMs >= walletOpTraceSlowMs ||
193
+ nonAppliedStatuses.length > 0) {
194
+ traceWalletOperation({
195
+ stage: 'confirmation-complete',
196
+ opHash: this.opHash,
197
+ elapsedMs,
198
+ expectedConfirmation,
199
+ currentConfirmation: confirmationResult?.currentConfirmation,
200
+ completed: confirmationResult?.completed,
201
+ statuses: summary.map((result) => result.status),
202
+ results: summary,
203
+ });
204
+ }
205
+ return confirmationResult;
206
+ }
207
+ catch (error) {
208
+ const operationResults = await this.getOperationResultsIfIncluded();
209
+ traceWalletOperation({
210
+ stage: 'confirmation-error',
211
+ opHash: this.opHash,
212
+ elapsedMs: Date.now() - startedAt,
213
+ expectedConfirmation,
214
+ error: toErrorMessage(error),
215
+ results: summarizeWalletOperationResults(operationResults),
216
+ });
217
+ throw error;
218
+ }
155
219
  }
156
220
  }
157
221
  exports.WalletOperation = WalletOperation;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.OriginationWalletOperation = void 0;
13
4
  const rpc_1 = require("@taquito/rpc");
@@ -20,46 +11,43 @@ class OriginationWalletOperation extends operation_1.WalletOperation {
20
11
  this.opHash = opHash;
21
12
  this.context = context;
22
13
  }
23
- originationOperation() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const operationResult = yield this.operationResults();
26
- if (operationResult) {
27
- return (0, types_1.findWithKind)(operationResult, rpc_1.OpKind.ORIGINATION);
28
- }
29
- else {
30
- throw new errors_1.ObservableError('Unable to fetch operation result');
31
- }
32
- });
14
+ async originationOperation() {
15
+ const operationResult = await this.operationResults();
16
+ if (operationResult) {
17
+ return (0, types_1.findWithKind)(operationResult, rpc_1.OpKind.ORIGINATION);
18
+ }
19
+ else {
20
+ throw new errors_1.ObservableError('Unable to fetch operation result');
21
+ }
33
22
  }
34
- revealOperation() {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const operationResult = yield this.operationResults();
37
- if (operationResult) {
38
- return (0, types_1.findWithKind)(operationResult, rpc_1.OpKind.REVEAL);
39
- }
40
- else {
41
- throw new errors_1.ObservableError('Unable to fetch operation result');
42
- }
43
- });
23
+ async revealOperation() {
24
+ const operationResult = await this.operationResults();
25
+ if (operationResult) {
26
+ return (0, types_1.findWithKind)(operationResult, rpc_1.OpKind.REVEAL);
27
+ }
28
+ else {
29
+ throw new errors_1.ObservableError('Unable to fetch operation result');
30
+ }
44
31
  }
45
- status() {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- if (!this._included) {
48
- return 'pending';
49
- }
50
- const op = yield this.originationOperation();
51
- if (!op) {
52
- return 'unknown';
53
- }
54
- return op.metadata.operation_result.status;
55
- });
32
+ async status() {
33
+ if (!this._included) {
34
+ return 'pending';
35
+ }
36
+ const op = await this.originationOperation();
37
+ if (!op) {
38
+ return 'unknown';
39
+ }
40
+ return op.metadata.operation_result.status;
56
41
  }
57
- contract() {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const op = yield this.originationOperation();
60
- const address = ((op === null || op === void 0 ? void 0 : op.metadata.operation_result.originated_contracts) || [])[0];
61
- return this.context.wallet.at(address);
62
- });
42
+ async contract() {
43
+ const op = await this.originationOperation();
44
+ const address = (op?.metadata.operation_result.originated_contracts || [])[0];
45
+ if (!address) {
46
+ throw new errors_1.OriginationWalletOperationError('No contract was originated in this operation');
47
+ }
48
+ await this.confirmation();
49
+ const inclusionBlock = await this.getInclusionBlock();
50
+ return this.context.wallet.at(address, undefined, inclusionBlock.header.level);
63
51
  }
64
52
  }
65
53
  exports.OriginationWalletOperation = OriginationWalletOperation;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.RegisterGlobalConstantWalletOperation = void 0;
13
4
  const rpc_1 = require("@taquito/rpc");
@@ -20,43 +11,35 @@ class RegisterGlobalConstantWalletOperation extends operation_1.WalletOperation
20
11
  this.opHash = opHash;
21
12
  this.context = context;
22
13
  }
23
- revealOperation() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const operationResult = yield this.operationResults();
26
- if (!operationResult) {
27
- throw new errors_1.ObservableError('operationResult returned undefined');
28
- }
29
- return operationResult.find((x) => x.kind === rpc_1.OpKind.REVEAL);
30
- });
14
+ async revealOperation() {
15
+ const operationResult = await this.operationResults();
16
+ if (!operationResult) {
17
+ throw new errors_1.ObservableError('operationResult returned undefined');
18
+ }
19
+ return operationResult.find((x) => x.kind === rpc_1.OpKind.REVEAL);
31
20
  }
32
- registerGlobalConstantOperation() {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const operationResult = yield this.operationResults();
35
- if (operationResult) {
36
- return (0, types_1.findWithKind)(operationResult, rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT);
37
- }
38
- else {
39
- throw new errors_1.ObservableError('Unable to fetch operation result');
40
- }
41
- });
21
+ async registerGlobalConstantOperation() {
22
+ const operationResult = await this.operationResults();
23
+ if (operationResult) {
24
+ return (0, types_1.findWithKind)(operationResult, rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT);
25
+ }
26
+ else {
27
+ throw new errors_1.ObservableError('Unable to fetch operation result');
28
+ }
42
29
  }
43
- status() {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- if (!this._included) {
46
- return 'pending';
47
- }
48
- const op = yield this.registerGlobalConstantOperation();
49
- if (!op) {
50
- return 'unknown';
51
- }
52
- return op.metadata.operation_result.status;
53
- });
30
+ async status() {
31
+ if (!this._included) {
32
+ return 'pending';
33
+ }
34
+ const op = await this.registerGlobalConstantOperation();
35
+ if (!op) {
36
+ return 'unknown';
37
+ }
38
+ return op.metadata.operation_result.status;
54
39
  }
55
- globalConstantHash() {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const op = yield this.registerGlobalConstantOperation();
58
- return op === null || op === void 0 ? void 0 : op.metadata.operation_result.global_address;
59
- });
40
+ async globalConstantHash() {
41
+ const op = await this.registerGlobalConstantOperation();
42
+ return op?.metadata.operation_result.global_address;
60
43
  }
61
44
  }
62
45
  exports.RegisterGlobalConstantWalletOperation = RegisterGlobalConstantWalletOperation;