@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.
- package/README.md +1 -1
- package/dist/lib/batch/rpc-batch-provider.js +91 -83
- package/dist/lib/context.js +22 -26
- package/dist/lib/contract/big-map.js +16 -29
- package/dist/lib/contract/contract-methods/contract-method-object-param.js +7 -7
- package/dist/lib/contract/contract-methods/contract-on-chain-view.js +31 -44
- package/dist/lib/contract/contract.js +21 -32
- package/dist/lib/contract/errors.js +9 -9
- package/dist/lib/contract/prepare.js +36 -45
- package/dist/lib/contract/rpc-contract-provider.js +426 -475
- package/dist/lib/contract/sapling-state-abstraction.js +3 -14
- package/dist/lib/contract/semantic.js +2 -2
- package/dist/lib/errors.js +3 -3
- package/dist/lib/estimate/errors.js +1 -1
- package/dist/lib/estimate/estimate.js +66 -20
- package/dist/lib/estimate/rpc-estimate-provider.js +427 -460
- package/dist/lib/forger/composite-forger.js +16 -27
- package/dist/lib/forger/errors.js +2 -2
- package/dist/lib/forger/taquito-local-forger.js +9 -22
- package/dist/lib/global-constants/default-global-constants-provider.js +8 -19
- package/dist/lib/global-constants/errors.js +2 -2
- package/dist/lib/global-constants/noop-global-constants-provider.js +2 -13
- package/dist/lib/import-key.js +23 -34
- package/dist/lib/injector/rpc-injector.js +13 -24
- package/dist/lib/operations/ballot-operation.js +2 -3
- package/dist/lib/operations/delegate-operation.js +5 -8
- package/dist/lib/operations/drain-delegate-operation.js +1 -1
- package/dist/lib/operations/errors.js +9 -6
- package/dist/lib/operations/increase-paid-storage-operation.js +4 -7
- package/dist/lib/operations/operations.js +100 -30
- package/dist/lib/operations/origination-operation.js +16 -27
- package/dist/lib/operations/proposals-operation.js +2 -3
- package/dist/lib/operations/register-global-constant-operation.js +4 -7
- package/dist/lib/operations/reveal-operation.js +1 -1
- package/dist/lib/operations/smart-rollup-add-messages-operation.js +4 -7
- package/dist/lib/operations/smart-rollup-execute-outbox-message-operation.js +4 -7
- package/dist/lib/operations/smart-rollup-originate-operation.js +4 -7
- package/dist/lib/operations/transaction-operation.js +2 -2
- package/dist/lib/operations/transfer-ticket-operation.js +4 -6
- package/dist/lib/operations/types.js +17 -19
- package/dist/lib/operations/update-companion-key-operation.js +4 -7
- package/dist/lib/operations/update-consensus-key-operation.js +4 -7
- package/dist/lib/packer/michel-codec-packer.js +3 -14
- package/dist/lib/packer/rpc-packer.js +2 -13
- package/dist/lib/parser/michel-codec-parser.js +82 -107
- package/dist/lib/parser/noop-parser.js +2 -13
- package/dist/lib/prepare/prepare-provider.js +780 -744
- package/dist/lib/provider.js +322 -128
- package/dist/lib/read-provider/rpc-read-adapter.js +76 -121
- package/dist/lib/signer/errors.js +1 -1
- package/dist/lib/signer/noop.js +9 -26
- package/dist/lib/subscribe/errors.js +2 -2
- package/dist/lib/subscribe/polling-subcribe-provider.js +35 -38
- package/dist/lib/taquito.js +33 -33
- package/dist/lib/tz/rpc-tz-provider.js +27 -44
- package/dist/lib/version.js +2 -2
- package/dist/lib/wallet/batch-operation.js +32 -45
- package/dist/lib/wallet/delegation-operation.js +25 -40
- package/dist/lib/wallet/errors.js +15 -3
- package/dist/lib/wallet/increase-paid-storage-operation.js +25 -40
- package/dist/lib/wallet/legacy.js +28 -63
- package/dist/lib/wallet/operation-factory.js +27 -56
- package/dist/lib/wallet/operation.js +123 -59
- package/dist/lib/wallet/origination-operation.js +34 -46
- package/dist/lib/wallet/register-global-constant-operation.js +26 -43
- package/dist/lib/wallet/transaction-operation.js +21 -36
- package/dist/lib/wallet/transfer-ticket-operation.js +21 -36
- package/dist/lib/wallet/wallet.js +187 -184
- package/dist/taquito.es6.js +3424 -3197
- package/dist/taquito.es6.js.map +1 -1
- package/dist/taquito.min.js +1 -1
- package/dist/taquito.umd.js +7930 -7701
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/batch/rpc-batch-provider.d.ts +18 -18
- package/dist/types/context.d.ts +4 -4
- package/dist/types/contract/big-map.d.ts +3 -3
- package/dist/types/contract/contract-methods/contract-method-interface.d.ts +4 -4
- package/dist/types/contract/contract-methods/contract-method-object-param.d.ts +6 -6
- package/dist/types/contract/contract-methods/contract-on-chain-view.d.ts +3 -3
- package/dist/types/contract/contract.d.ts +6 -6
- package/dist/types/contract/errors.d.ts +11 -11
- package/dist/types/contract/interface.d.ts +42 -42
- package/dist/types/contract/rpc-contract-provider.d.ts +44 -43
- package/dist/types/contract/sapling-state-abstraction.d.ts +1 -1
- package/dist/types/contract/semantic.d.ts +2 -2
- package/dist/types/errors.d.ts +5 -5
- package/dist/types/estimate/errors.d.ts +1 -1
- package/dist/types/estimate/estimate-provider-interface.d.ts +81 -84
- package/dist/types/estimate/estimate.d.ts +28 -11
- package/dist/types/estimate/rpc-estimate-provider.d.ts +34 -30
- package/dist/types/forger/errors.d.ts +2 -2
- package/dist/types/global-constants/default-global-constants-provider.d.ts +2 -2
- package/dist/types/global-constants/errors.d.ts +2 -2
- package/dist/types/global-constants/interface-global-constants-provider.d.ts +1 -1
- package/dist/types/import-key.d.ts +2 -2
- package/dist/types/operations/ballot-operation.d.ts +1 -1
- package/dist/types/operations/delegate-operation.d.ts +2 -2
- package/dist/types/operations/drain-delegate-operation.d.ts +1 -1
- package/dist/types/operations/errors.d.ts +5 -5
- package/dist/types/operations/failing-noop-operation.d.ts +1 -1
- package/dist/types/operations/increase-paid-storage-operation.d.ts +1 -1
- package/dist/types/operations/operations.d.ts +2 -2
- package/dist/types/operations/origination-operation.d.ts +5 -5
- package/dist/types/operations/proposals-operation.d.ts +1 -1
- package/dist/types/operations/register-global-constant-operation.d.ts +2 -2
- package/dist/types/operations/reveal-operation.d.ts +1 -1
- package/dist/types/operations/smart-rollup-add-messages-operation.d.ts +1 -1
- package/dist/types/operations/smart-rollup-execute-outbox-message-operation.d.ts +1 -1
- package/dist/types/operations/smart-rollup-originate-operation.d.ts +1 -1
- package/dist/types/operations/transaction-operation.d.ts +2 -2
- package/dist/types/operations/transfer-ticket-operation.d.ts +2 -2
- package/dist/types/operations/types.d.ts +387 -25
- package/dist/types/operations/update-companion-key-operation.d.ts +1 -1
- package/dist/types/operations/update-consensus-key-operation.d.ts +1 -1
- package/dist/types/prepare/interface.d.ts +32 -33
- package/dist/types/prepare/prepare-provider.d.ts +34 -60
- package/dist/types/provider.d.ts +7 -1
- package/dist/types/read-provider/interface.d.ts +21 -21
- package/dist/types/read-provider/rpc-read-adapter.d.ts +22 -22
- package/dist/types/signer/errors.d.ts +1 -1
- package/dist/types/signer/noop.d.ts +1 -1
- package/dist/types/subscribe/errors.d.ts +2 -2
- package/dist/types/taquito.d.ts +33 -33
- package/dist/types/wallet/errors.d.ts +10 -2
- package/dist/types/wallet/interface.d.ts +13 -13
- package/dist/types/wallet/operation.d.ts +4 -3
- package/dist/types/wallet/wallet.d.ts +36 -35
- package/package.json +27 -15
- 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
|
|
20
|
-
return this.context.signer.publicKeyHash();
|
|
21
|
-
});
|
|
9
|
+
async getPKH() {
|
|
10
|
+
return this.context.signer.publicKeyHash();
|
|
22
11
|
}
|
|
23
|
-
getPK() {
|
|
24
|
-
return
|
|
25
|
-
return this.context.signer.publicKey();
|
|
26
|
-
});
|
|
12
|
+
async getPK() {
|
|
13
|
+
return this.context.signer.publicKey();
|
|
27
14
|
}
|
|
28
|
-
mapTransferParamsToWalletParams(params) {
|
|
29
|
-
return
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
81
|
-
|
|
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
|
|
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) =>
|
|
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(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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(
|
|
77
|
-
return
|
|
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(
|
|
82
|
-
return
|
|
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(
|
|
87
|
-
return
|
|
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(
|
|
92
|
-
return
|
|
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(
|
|
97
|
-
return
|
|
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(
|
|
102
|
-
return
|
|
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(
|
|
107
|
-
return
|
|
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(
|
|
112
|
-
return
|
|
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
|
-
*
|
|
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
|
|
27
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
57
|
-
|
|
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;
|