@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
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
3
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
4
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -19,17 +10,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
12
|
};
|
|
22
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
23
|
-
var t = {};
|
|
24
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25
|
-
t[p] = s[p];
|
|
26
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
27
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
29
|
-
t[p[i]] = s[p[i]];
|
|
30
|
-
}
|
|
31
|
-
return t;
|
|
32
|
-
};
|
|
33
13
|
var _PrepareProvider_counters;
|
|
34
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
15
|
exports.PrepareProvider = void 0;
|
|
@@ -43,15 +23,14 @@ const provider_1 = require("../provider");
|
|
|
43
23
|
const bignumber_js_1 = require("bignumber.js");
|
|
44
24
|
const utils_1 = require("@taquito/utils");
|
|
45
25
|
const mergeLimits = (userDefinedLimit, defaultLimits) => {
|
|
46
|
-
var _a, _b, _c;
|
|
47
26
|
return {
|
|
48
|
-
fee:
|
|
49
|
-
gasLimit:
|
|
50
|
-
storageLimit:
|
|
27
|
+
fee: userDefinedLimit.fee ?? defaultLimits.fee,
|
|
28
|
+
gasLimit: userDefinedLimit.gasLimit ?? defaultLimits.gasLimit,
|
|
29
|
+
storageLimit: userDefinedLimit.storageLimit ?? defaultLimits.storageLimit,
|
|
51
30
|
};
|
|
52
31
|
};
|
|
53
32
|
/**
|
|
54
|
-
*
|
|
33
|
+
* PrepareProvider is a utility class to output the prepared format of an operation
|
|
55
34
|
*/
|
|
56
35
|
class PrepareProvider extends provider_1.Provider {
|
|
57
36
|
constructor(context) {
|
|
@@ -60,35 +39,40 @@ class PrepareProvider extends provider_1.Provider {
|
|
|
60
39
|
_PrepareProvider_counters.set(this, void 0);
|
|
61
40
|
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
62
41
|
}
|
|
63
|
-
getBlockHash(block) {
|
|
64
|
-
return
|
|
65
|
-
return this.context.readProvider.getBlockHash(block !== null && block !== void 0 ? block : 'head~2');
|
|
66
|
-
});
|
|
42
|
+
async getBlockHash(block) {
|
|
43
|
+
return this.context.readProvider.getBlockHash(block ?? 'head~2');
|
|
67
44
|
}
|
|
68
|
-
getProtocolHash() {
|
|
69
|
-
return
|
|
70
|
-
return this.context.readProvider.getNextProtocol('head');
|
|
71
|
-
});
|
|
45
|
+
async getProtocolHash() {
|
|
46
|
+
return this.context.readProvider.getNextProtocol('head');
|
|
72
47
|
}
|
|
73
|
-
getHeadCounter(pkh) {
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
48
|
+
async getHeadCounter(pkh) {
|
|
49
|
+
return this.context.readProvider.getCounter(pkh, 'head') ?? '0';
|
|
50
|
+
}
|
|
51
|
+
adjustGasForManagerOperations(gasLimitBlock, gaslimitOp, opsNeedingGasLimitPatch, explicitGasLimitTotal = new bignumber_js_1.default(0)) {
|
|
52
|
+
if (opsNeedingGasLimitPatch <= 0) {
|
|
53
|
+
return gaslimitOp;
|
|
54
|
+
}
|
|
55
|
+
const remainingBlockGas = gasLimitBlock.minus(explicitGasLimitTotal);
|
|
56
|
+
if (remainingBlockGas.lte(0)) {
|
|
57
|
+
return new bignumber_js_1.default(0);
|
|
58
|
+
}
|
|
59
|
+
return bignumber_js_1.default.min(gaslimitOp, remainingBlockGas.div(opsNeedingGasLimitPatch).integerValue(bignumber_js_1.default.ROUND_DOWN));
|
|
60
|
+
}
|
|
61
|
+
getOperationLimits(constants, options = {}) {
|
|
62
|
+
const { hard_gas_limit_per_operation, hard_gas_limit_per_block, hard_storage_limit_per_operation, } = constants;
|
|
63
|
+
return {
|
|
64
|
+
fee: 0,
|
|
65
|
+
gasLimit: this.adjustGasForManagerOperations(hard_gas_limit_per_block, hard_gas_limit_per_operation, options.opsNeedingGasLimitPatch ?? 0, options.explicitGasLimitTotal).toNumber(),
|
|
66
|
+
storageLimit: hard_storage_limit_per_operation.toNumber(),
|
|
67
|
+
};
|
|
78
68
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
fee: 0,
|
|
87
|
-
gasLimit: numberOfOps
|
|
88
|
-
? Math.floor(this.adjustGasForBatchOperation(hard_gas_limit_per_block, hard_gas_limit_per_operation, numberOfOps).toNumber())
|
|
89
|
-
: hard_gas_limit_per_operation.toNumber(),
|
|
90
|
-
storageLimit: hard_storage_limit_per_operation.toNumber(),
|
|
91
|
-
};
|
|
69
|
+
async getOperationLimitsForManagerOperation(constants, publicKeyHash, kind, gasLimit) {
|
|
70
|
+
const revealNeeded = await this.isRevealOpNeeded([{ kind }], publicKeyHash);
|
|
71
|
+
return this.getOperationLimits(constants, {
|
|
72
|
+
opsNeedingGasLimitPatch: typeof gasLimit === 'undefined' ? 1 : 0,
|
|
73
|
+
explicitGasLimitTotal: revealNeeded
|
|
74
|
+
? new bignumber_js_1.default((0, constants_1.getRevealGasLimit)(publicKeyHash))
|
|
75
|
+
: undefined,
|
|
92
76
|
});
|
|
93
77
|
}
|
|
94
78
|
getFee(op, pkh, headCounter) {
|
|
@@ -106,42 +90,36 @@ class PrepareProvider extends provider_1.Provider {
|
|
|
106
90
|
getSource(op, pkh, source) {
|
|
107
91
|
return { source: typeof op.source === 'undefined' ? source || pkh : op.source };
|
|
108
92
|
}
|
|
109
|
-
addRevealOperationIfNeeded(operation, publicKeyHash) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
throw new core_1.PublicKeyNotFoundError(pkh);
|
|
117
|
-
}
|
|
118
|
-
const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(pkh, utils_1.publicKeyHashPrefixes);
|
|
119
|
-
ops.unshift(yield (0, contract_1.createRevealOperation)({
|
|
120
|
-
fee: (0, constants_1.getRevealFee)(pkh),
|
|
121
|
-
storageLimit: constants_1.REVEAL_STORAGE_LIMIT,
|
|
122
|
-
gasLimit: (0, constants_1.getRevealGasLimit)(pkh),
|
|
123
|
-
proof: pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash
|
|
124
|
-
? (yield this.signer.provePossession()).prefixSig
|
|
125
|
-
: undefined,
|
|
126
|
-
}, publicKeyHash, publicKey));
|
|
127
|
-
return ops;
|
|
93
|
+
async addRevealOperationIfNeeded(operation, publicKeyHash) {
|
|
94
|
+
if ((0, types_1.isOpRequireReveal)(operation)) {
|
|
95
|
+
const ops = [operation];
|
|
96
|
+
const { publicKey, pkh } = await this.getKeys();
|
|
97
|
+
if (await this.isAccountRevealRequired(publicKeyHash)) {
|
|
98
|
+
if (!publicKey) {
|
|
99
|
+
throw new core_1.PublicKeyNotFoundError(pkh);
|
|
128
100
|
}
|
|
101
|
+
const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(pkh, utils_1.publicKeyHashPrefixes);
|
|
102
|
+
ops.unshift(await (0, contract_1.createRevealOperation)({
|
|
103
|
+
fee: (0, constants_1.getRevealFee)(pkh),
|
|
104
|
+
storageLimit: constants_1.REVEAL_STORAGE_LIMIT,
|
|
105
|
+
gasLimit: (0, constants_1.getRevealGasLimit)(pkh),
|
|
106
|
+
proof: pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash
|
|
107
|
+
? (await this.signer.provePossession()).prefixSig
|
|
108
|
+
: undefined,
|
|
109
|
+
}, publicKeyHash, publicKey));
|
|
110
|
+
return ops;
|
|
129
111
|
}
|
|
130
|
-
|
|
131
|
-
|
|
112
|
+
}
|
|
113
|
+
return operation;
|
|
132
114
|
}
|
|
133
|
-
getKeys() {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
? yield this.signer.publicKey()
|
|
142
|
-
: yield this.context.wallet.pk(),
|
|
143
|
-
};
|
|
144
|
-
});
|
|
115
|
+
async getKeys() {
|
|
116
|
+
const isSignerConfigured = this.context.isAnySignerConfigured();
|
|
117
|
+
return {
|
|
118
|
+
pkh: isSignerConfigured ? await this.signer.publicKeyHash() : await this.context.wallet.pkh(),
|
|
119
|
+
publicKey: isSignerConfigured
|
|
120
|
+
? await this.signer.publicKey()
|
|
121
|
+
: await this.context.wallet.pk(),
|
|
122
|
+
};
|
|
145
123
|
}
|
|
146
124
|
convertIntoArray(op) {
|
|
147
125
|
if (Array.isArray(op)) {
|
|
@@ -151,16 +129,50 @@ class PrepareProvider extends provider_1.Provider {
|
|
|
151
129
|
return [op];
|
|
152
130
|
}
|
|
153
131
|
}
|
|
132
|
+
getSingleManagerOperationSimulation(ops, gasLimit) {
|
|
133
|
+
if (typeof gasLimit !== 'undefined' || ops.length === 0) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
gasLimitPatchableIndexes: [ops.length - 1],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
withSimulationMetadata(preparedOperation, simulation) {
|
|
141
|
+
if (!simulation) {
|
|
142
|
+
return preparedOperation;
|
|
143
|
+
}
|
|
144
|
+
// Keep retry bookkeeping available to estimation without changing the
|
|
145
|
+
// enumerable shape of single-op prepared results.
|
|
146
|
+
Object.defineProperty(preparedOperation, 'simulation', {
|
|
147
|
+
value: simulation,
|
|
148
|
+
configurable: true,
|
|
149
|
+
enumerable: false,
|
|
150
|
+
writable: true,
|
|
151
|
+
});
|
|
152
|
+
return preparedOperation;
|
|
153
|
+
}
|
|
154
154
|
constructOpContents(ops, headCounter, pkh, source, currentVotingPeriod) {
|
|
155
155
|
return ops.map((op) => {
|
|
156
156
|
switch (op.kind) {
|
|
157
157
|
case rpc_1.OpKind.ACTIVATION:
|
|
158
158
|
case rpc_1.OpKind.DRAIN_DELEGATE:
|
|
159
|
-
return
|
|
159
|
+
return {
|
|
160
|
+
...op,
|
|
161
|
+
};
|
|
160
162
|
case rpc_1.OpKind.ORIGINATION:
|
|
161
|
-
return
|
|
163
|
+
return {
|
|
164
|
+
...op,
|
|
165
|
+
balance: typeof op.balance !== 'undefined' ? `${op.balance}` : '0',
|
|
166
|
+
...this.getSource(op, pkh, source),
|
|
167
|
+
...this.getFee(op, pkh, headCounter),
|
|
168
|
+
};
|
|
162
169
|
case rpc_1.OpKind.TRANSACTION: {
|
|
163
|
-
const cops =
|
|
170
|
+
const cops = {
|
|
171
|
+
...op,
|
|
172
|
+
amount: typeof op.amount !== 'undefined' ? `${op.amount}` : '0',
|
|
173
|
+
...this.getSource(op, pkh, source),
|
|
174
|
+
...this.getFee(op, pkh, headCounter),
|
|
175
|
+
};
|
|
164
176
|
if (cops.source.toLowerCase().startsWith('kt1')) {
|
|
165
177
|
throw new core_1.DeprecationError(`KT1 addresses are not supported as source since ${constants_1.Protocols.PsBabyM1}`);
|
|
166
178
|
}
|
|
@@ -174,21 +186,43 @@ class PrepareProvider extends provider_1.Provider {
|
|
|
174
186
|
case rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
|
175
187
|
case rpc_1.OpKind.SMART_ROLLUP_ORIGINATE:
|
|
176
188
|
case rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:
|
|
177
|
-
return
|
|
189
|
+
return {
|
|
190
|
+
...op,
|
|
191
|
+
...this.getSource(op, pkh, source),
|
|
192
|
+
...this.getFee(op, pkh, headCounter),
|
|
193
|
+
};
|
|
178
194
|
case rpc_1.OpKind.TRANSFER_TICKET:
|
|
179
|
-
return
|
|
195
|
+
return {
|
|
196
|
+
...op,
|
|
197
|
+
ticket_amount: `${op.ticket_amount}`,
|
|
198
|
+
...this.getSource(op, pkh, source),
|
|
199
|
+
...this.getFee(op, pkh, headCounter),
|
|
200
|
+
};
|
|
180
201
|
case rpc_1.OpKind.INCREASE_PAID_STORAGE:
|
|
181
|
-
return
|
|
202
|
+
return {
|
|
203
|
+
...op,
|
|
204
|
+
amount: `${op.amount}`,
|
|
205
|
+
...this.getSource(op, pkh, source),
|
|
206
|
+
...this.getFee(op, pkh, headCounter),
|
|
207
|
+
};
|
|
182
208
|
case rpc_1.OpKind.BALLOT:
|
|
183
209
|
if (currentVotingPeriod === undefined) {
|
|
184
210
|
throw new errors_1.RPCResponseError(`Failed to get the current voting period index`);
|
|
185
211
|
}
|
|
186
|
-
return
|
|
212
|
+
return {
|
|
213
|
+
...op,
|
|
214
|
+
period: currentVotingPeriod?.voting_period.index,
|
|
215
|
+
...this.getSource(op, pkh, source),
|
|
216
|
+
};
|
|
187
217
|
case rpc_1.OpKind.PROPOSALS:
|
|
188
218
|
if (currentVotingPeriod === undefined) {
|
|
189
219
|
throw new errors_1.RPCResponseError(`Failed to get the current voting period index`);
|
|
190
220
|
}
|
|
191
|
-
return
|
|
221
|
+
return {
|
|
222
|
+
...op,
|
|
223
|
+
period: currentVotingPeriod?.voting_period.index,
|
|
224
|
+
...this.getSource(op, pkh, source),
|
|
225
|
+
};
|
|
192
226
|
default:
|
|
193
227
|
throw new core_1.InvalidOperationKindError(op.kind);
|
|
194
228
|
}
|
|
@@ -196,806 +230,808 @@ class PrepareProvider extends provider_1.Provider {
|
|
|
196
230
|
}
|
|
197
231
|
/**
|
|
198
232
|
*
|
|
199
|
-
*
|
|
200
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
201
|
-
* @param source string or undefined source pkh
|
|
233
|
+
* Method to prepare an activation operation
|
|
202
234
|
* @returns a PreparedOperation object
|
|
203
235
|
*/
|
|
204
|
-
activate(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
secret,
|
|
209
|
-
});
|
|
210
|
-
const ops = this.convertIntoArray(op);
|
|
211
|
-
const hash = yield this.getBlockHash();
|
|
212
|
-
const protocol = yield this.getProtocolHash();
|
|
213
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
214
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
215
|
-
const contents = this.constructOpContents(ops, headCounter, pkh);
|
|
216
|
-
return {
|
|
217
|
-
opOb: {
|
|
218
|
-
branch: hash,
|
|
219
|
-
contents,
|
|
220
|
-
protocol,
|
|
221
|
-
},
|
|
222
|
-
counter: headCounter,
|
|
223
|
-
};
|
|
236
|
+
async activate({ pkh, secret }) {
|
|
237
|
+
const op = await (0, contract_1.createActivationOperation)({
|
|
238
|
+
pkh,
|
|
239
|
+
secret,
|
|
224
240
|
});
|
|
241
|
+
const ops = this.convertIntoArray(op);
|
|
242
|
+
const hash = await this.getBlockHash();
|
|
243
|
+
const protocol = await this.getProtocolHash();
|
|
244
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
245
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
246
|
+
const contents = this.constructOpContents(ops, headCounter, pkh);
|
|
247
|
+
const preparedOperation = {
|
|
248
|
+
opOb: {
|
|
249
|
+
branch: hash,
|
|
250
|
+
contents,
|
|
251
|
+
protocol,
|
|
252
|
+
},
|
|
253
|
+
counter: headCounter,
|
|
254
|
+
};
|
|
255
|
+
return preparedOperation;
|
|
225
256
|
}
|
|
226
257
|
/**
|
|
227
258
|
*
|
|
228
|
-
*
|
|
229
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
230
|
-
* @param source string or undefined source pkh
|
|
259
|
+
* Method to prepare a reveal operation
|
|
231
260
|
* @returns a PreparedOperation object
|
|
232
261
|
*/
|
|
233
|
-
reveal(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
(0, utils_1.b58DecodeAndCheckPrefix)(proof, [utils_1.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
const { prefixSig } = yield this.signer.provePossession();
|
|
246
|
-
proof = prefixSig;
|
|
247
|
-
}
|
|
262
|
+
async reveal({ fee, gasLimit, storageLimit, proof }) {
|
|
263
|
+
const { pkh, publicKey } = await this.getKeys();
|
|
264
|
+
if (!publicKey) {
|
|
265
|
+
throw new core_1.PublicKeyNotFoundError(pkh);
|
|
266
|
+
}
|
|
267
|
+
const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(pkh, utils_1.publicKeyHashPrefixes);
|
|
268
|
+
if (pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash) {
|
|
269
|
+
if (proof) {
|
|
270
|
+
(0, utils_1.b58DecodeAndCheckPrefix)(proof, [utils_1.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
248
271
|
}
|
|
249
272
|
else {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
273
|
+
const { prefixSig } = await this.signer.provePossession();
|
|
274
|
+
proof = prefixSig;
|
|
253
275
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
if (proof) {
|
|
279
|
+
throw new core_1.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
283
|
+
const DEFAULT_PARAMS = await this.getOperationLimits(protocolConstants);
|
|
284
|
+
const mergedEstimates = mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS);
|
|
285
|
+
const op = await (0, contract_1.createRevealOperation)({
|
|
286
|
+
fee: mergedEstimates.fee,
|
|
287
|
+
gasLimit: mergedEstimates.gasLimit,
|
|
288
|
+
storageLimit: mergedEstimates.storageLimit,
|
|
289
|
+
proof,
|
|
290
|
+
}, pkh, publicKey);
|
|
291
|
+
const ops = this.convertIntoArray(op);
|
|
292
|
+
const hash = await this.getBlockHash();
|
|
293
|
+
const protocol = await this.getProtocolHash();
|
|
294
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
295
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
296
|
+
const contents = this.constructOpContents(ops, headCounter, pkh);
|
|
297
|
+
const preparedOperation = {
|
|
298
|
+
opOb: {
|
|
299
|
+
branch: hash,
|
|
300
|
+
contents,
|
|
301
|
+
protocol,
|
|
302
|
+
},
|
|
303
|
+
counter: headCounter,
|
|
304
|
+
};
|
|
305
|
+
return preparedOperation;
|
|
278
306
|
}
|
|
279
307
|
/**
|
|
280
308
|
*
|
|
281
|
-
*
|
|
282
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
309
|
+
* Method to prepare an origination operation
|
|
283
310
|
* @param source string or undefined source pkh
|
|
284
311
|
* @returns a PreparedOperation object
|
|
285
312
|
*/
|
|
286
|
-
originate(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
313
|
+
async originate({ fee, storageLimit, gasLimit, ...rest }, source) {
|
|
314
|
+
const { pkh } = await this.getKeys();
|
|
315
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
316
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.ORIGINATION, gasLimit);
|
|
317
|
+
const op = await (0, contract_1.createOriginationOperation)(await this.context.parser.prepareCodeOrigination({
|
|
318
|
+
...rest,
|
|
319
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
320
|
+
}));
|
|
321
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
322
|
+
const ops = this.convertIntoArray(operation);
|
|
323
|
+
const hash = await this.getBlockHash();
|
|
324
|
+
const protocol = await this.getProtocolHash();
|
|
325
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
326
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
327
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
328
|
+
const preparedOperation = {
|
|
329
|
+
opOb: {
|
|
330
|
+
branch: hash,
|
|
331
|
+
contents,
|
|
332
|
+
protocol,
|
|
333
|
+
},
|
|
334
|
+
counter: headCounter,
|
|
335
|
+
};
|
|
336
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
309
337
|
}
|
|
310
338
|
/**
|
|
311
339
|
*
|
|
312
|
-
*
|
|
313
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
314
|
-
* @param source string or undefined source pkh
|
|
340
|
+
* Method to prepare a transaction operation
|
|
315
341
|
* @returns a PreparedOperation object
|
|
316
342
|
*/
|
|
317
|
-
transaction(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
325
|
-
const ops = this.convertIntoArray(operation);
|
|
326
|
-
const hash = yield this.getBlockHash();
|
|
327
|
-
const protocol = yield this.getProtocolHash();
|
|
328
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
329
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
330
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
331
|
-
return {
|
|
332
|
-
opOb: {
|
|
333
|
-
branch: hash,
|
|
334
|
-
contents,
|
|
335
|
-
protocol,
|
|
336
|
-
},
|
|
337
|
-
counter: headCounter,
|
|
338
|
-
};
|
|
343
|
+
async transaction({ fee, storageLimit, gasLimit, ...rest }) {
|
|
344
|
+
const { pkh } = await this.getKeys();
|
|
345
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
346
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.TRANSACTION, gasLimit);
|
|
347
|
+
const op = await (0, contract_1.createTransferOperation)({
|
|
348
|
+
...rest,
|
|
349
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
339
350
|
});
|
|
351
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
352
|
+
const ops = this.convertIntoArray(operation);
|
|
353
|
+
const hash = await this.getBlockHash();
|
|
354
|
+
const protocol = await this.getProtocolHash();
|
|
355
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
356
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
357
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
358
|
+
const preparedOperation = {
|
|
359
|
+
opOb: {
|
|
360
|
+
branch: hash,
|
|
361
|
+
contents,
|
|
362
|
+
protocol,
|
|
363
|
+
},
|
|
364
|
+
counter: headCounter,
|
|
365
|
+
};
|
|
366
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
340
367
|
}
|
|
341
368
|
/**
|
|
342
369
|
*
|
|
343
|
-
*
|
|
344
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
345
|
-
* @param source string or undefined source pkh
|
|
370
|
+
* Method to prepare a stake pseudo-operation
|
|
346
371
|
* @returns a PreparedOperation object
|
|
347
372
|
*/
|
|
348
|
-
stake(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
361
|
-
const ops = this.convertIntoArray(operation);
|
|
362
|
-
const hash = yield this.getBlockHash();
|
|
363
|
-
const protocol = yield this.getProtocolHash();
|
|
364
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
365
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
366
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
367
|
-
return {
|
|
368
|
-
opOb: {
|
|
369
|
-
branch: hash,
|
|
370
|
-
contents,
|
|
371
|
-
protocol,
|
|
373
|
+
async stake({ fee, storageLimit, gasLimit, ...rest }) {
|
|
374
|
+
const { pkh } = await this.getKeys();
|
|
375
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
376
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.TRANSACTION, gasLimit);
|
|
377
|
+
const op = await (0, contract_1.createTransferOperation)({
|
|
378
|
+
...rest,
|
|
379
|
+
to: pkh,
|
|
380
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
381
|
+
parameter: {
|
|
382
|
+
entrypoint: 'stake',
|
|
383
|
+
value: {
|
|
384
|
+
prim: 'Unit',
|
|
372
385
|
},
|
|
373
|
-
|
|
374
|
-
};
|
|
386
|
+
},
|
|
375
387
|
});
|
|
388
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
389
|
+
const ops = this.convertIntoArray(operation);
|
|
390
|
+
const hash = await this.getBlockHash();
|
|
391
|
+
const protocol = await this.getProtocolHash();
|
|
392
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
393
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
394
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
395
|
+
const preparedOperation = {
|
|
396
|
+
opOb: {
|
|
397
|
+
branch: hash,
|
|
398
|
+
contents,
|
|
399
|
+
protocol,
|
|
400
|
+
},
|
|
401
|
+
counter: headCounter,
|
|
402
|
+
};
|
|
403
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
376
404
|
}
|
|
377
405
|
/**
|
|
378
406
|
*
|
|
379
|
-
*
|
|
380
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
381
|
-
* @param source string or undefined source pkh
|
|
407
|
+
* Method to prepare a unstake pseudo-operation
|
|
382
408
|
* @returns a PreparedOperation object
|
|
383
409
|
*/
|
|
384
|
-
unstake(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const hash = yield this.getBlockHash();
|
|
397
|
-
const protocol = yield this.getProtocolHash();
|
|
398
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
399
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
400
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
401
|
-
return {
|
|
402
|
-
opOb: {
|
|
403
|
-
branch: hash,
|
|
404
|
-
contents,
|
|
405
|
-
protocol,
|
|
406
|
-
},
|
|
407
|
-
counter: headCounter,
|
|
408
|
-
};
|
|
410
|
+
async unstake({ fee, storageLimit, gasLimit, ...rest }) {
|
|
411
|
+
const { pkh } = await this.getKeys();
|
|
412
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
413
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.TRANSACTION, gasLimit);
|
|
414
|
+
const op = await (0, contract_1.createTransferOperation)({
|
|
415
|
+
...rest,
|
|
416
|
+
to: pkh,
|
|
417
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
418
|
+
parameter: {
|
|
419
|
+
entrypoint: 'unstake',
|
|
420
|
+
value: { prim: 'Unit' },
|
|
421
|
+
},
|
|
409
422
|
});
|
|
423
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
424
|
+
const ops = this.convertIntoArray(operation);
|
|
425
|
+
const hash = await this.getBlockHash();
|
|
426
|
+
const protocol = await this.getProtocolHash();
|
|
427
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
428
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
429
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
430
|
+
const preparedOperation = {
|
|
431
|
+
opOb: {
|
|
432
|
+
branch: hash,
|
|
433
|
+
contents,
|
|
434
|
+
protocol,
|
|
435
|
+
},
|
|
436
|
+
counter: headCounter,
|
|
437
|
+
};
|
|
438
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
410
439
|
}
|
|
411
440
|
/**
|
|
412
441
|
*
|
|
413
|
-
*
|
|
414
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
415
|
-
* @param source string or undefined source pkh
|
|
442
|
+
* Method to prepare a finalize_unstake pseudo-operation
|
|
416
443
|
* @returns a PreparedOperation object
|
|
417
444
|
*/
|
|
418
|
-
finalizeUnstake(
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const protocol = yield this.getProtocolHash();
|
|
432
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
433
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
434
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
435
|
-
return {
|
|
436
|
-
opOb: {
|
|
437
|
-
branch: hash,
|
|
438
|
-
contents,
|
|
439
|
-
protocol,
|
|
440
|
-
},
|
|
441
|
-
counter: headCounter,
|
|
442
|
-
};
|
|
445
|
+
async finalizeUnstake({ fee, storageLimit, gasLimit, to, ...rest }) {
|
|
446
|
+
const { pkh } = await this.getKeys();
|
|
447
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
448
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.TRANSACTION, gasLimit);
|
|
449
|
+
const op = await (0, contract_1.createTransferOperation)({
|
|
450
|
+
...rest,
|
|
451
|
+
to: to ? to : pkh,
|
|
452
|
+
amount: 0,
|
|
453
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
454
|
+
parameter: {
|
|
455
|
+
entrypoint: 'finalize_unstake',
|
|
456
|
+
value: { prim: 'Unit' },
|
|
457
|
+
},
|
|
443
458
|
});
|
|
459
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
460
|
+
const ops = this.convertIntoArray(operation);
|
|
461
|
+
const hash = await this.getBlockHash();
|
|
462
|
+
const protocol = await this.getProtocolHash();
|
|
463
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
464
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
465
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
466
|
+
const preparedOperation = {
|
|
467
|
+
opOb: {
|
|
468
|
+
branch: hash,
|
|
469
|
+
contents,
|
|
470
|
+
protocol,
|
|
471
|
+
},
|
|
472
|
+
counter: headCounter,
|
|
473
|
+
};
|
|
474
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
444
475
|
}
|
|
445
476
|
/**
|
|
446
477
|
*
|
|
447
|
-
*
|
|
448
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
449
|
-
* @param source string or undefined source pkh
|
|
478
|
+
* Method to prepare a delegation operation
|
|
450
479
|
* @returns a PreparedOperation object
|
|
451
480
|
*/
|
|
452
|
-
delegation(
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
460
|
-
const ops = this.convertIntoArray(operation);
|
|
461
|
-
const hash = yield this.getBlockHash();
|
|
462
|
-
const protocol = yield this.getProtocolHash();
|
|
463
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
464
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
465
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
466
|
-
return {
|
|
467
|
-
opOb: {
|
|
468
|
-
branch: hash,
|
|
469
|
-
contents,
|
|
470
|
-
protocol,
|
|
471
|
-
},
|
|
472
|
-
counter: headCounter,
|
|
473
|
-
};
|
|
481
|
+
async delegation({ fee, storageLimit, gasLimit, ...rest }) {
|
|
482
|
+
const { pkh } = await this.getKeys();
|
|
483
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
484
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.DELEGATION, gasLimit);
|
|
485
|
+
const op = await (0, contract_1.createSetDelegateOperation)({
|
|
486
|
+
...rest,
|
|
487
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
474
488
|
});
|
|
489
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
490
|
+
const ops = this.convertIntoArray(operation);
|
|
491
|
+
const hash = await this.getBlockHash();
|
|
492
|
+
const protocol = await this.getProtocolHash();
|
|
493
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
494
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
495
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
496
|
+
const preparedOperation = {
|
|
497
|
+
opOb: {
|
|
498
|
+
branch: hash,
|
|
499
|
+
contents,
|
|
500
|
+
protocol,
|
|
501
|
+
},
|
|
502
|
+
counter: headCounter,
|
|
503
|
+
};
|
|
504
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
475
505
|
}
|
|
476
506
|
/**
|
|
477
507
|
*
|
|
478
|
-
*
|
|
479
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
508
|
+
* Method to prepare a register delegate operation
|
|
480
509
|
* @param source string or undefined source pkh
|
|
481
510
|
* @returns a PreparedOperation object
|
|
482
511
|
*/
|
|
483
|
-
registerDelegate(
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
});
|
|
512
|
+
async registerDelegate({ fee, storageLimit, gasLimit }, source) {
|
|
513
|
+
const { pkh } = await this.getKeys();
|
|
514
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
515
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.DELEGATION, gasLimit);
|
|
516
|
+
const mergedEstimates = mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS);
|
|
517
|
+
const op = await (0, contract_1.createRegisterDelegateOperation)({
|
|
518
|
+
fee: mergedEstimates.fee,
|
|
519
|
+
storageLimit: mergedEstimates.storageLimit,
|
|
520
|
+
gasLimit: mergedEstimates.gasLimit,
|
|
521
|
+
}, pkh);
|
|
522
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
523
|
+
const ops = this.convertIntoArray(operation);
|
|
524
|
+
const hash = await this.getBlockHash();
|
|
525
|
+
const protocol = await this.getProtocolHash();
|
|
526
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
527
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
528
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
529
|
+
const preparedOperation = {
|
|
530
|
+
opOb: {
|
|
531
|
+
branch: hash,
|
|
532
|
+
contents,
|
|
533
|
+
protocol,
|
|
534
|
+
},
|
|
535
|
+
counter: headCounter,
|
|
536
|
+
};
|
|
537
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
510
538
|
}
|
|
511
539
|
/**
|
|
512
540
|
*
|
|
513
|
-
*
|
|
514
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
515
|
-
* @param source string or undefined source pkh
|
|
541
|
+
* Method to prepare a register_global_constant operation
|
|
516
542
|
* @returns a PreparedOperation object
|
|
517
543
|
*/
|
|
518
|
-
registerGlobalConstant(
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
526
|
-
const ops = this.convertIntoArray(operation);
|
|
527
|
-
const hash = yield this.getBlockHash();
|
|
528
|
-
const protocol = yield this.getProtocolHash();
|
|
529
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
530
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
531
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
532
|
-
return {
|
|
533
|
-
opOb: {
|
|
534
|
-
branch: hash,
|
|
535
|
-
contents,
|
|
536
|
-
protocol,
|
|
537
|
-
},
|
|
538
|
-
counter: headCounter,
|
|
539
|
-
};
|
|
544
|
+
async registerGlobalConstant({ fee, storageLimit, gasLimit, ...rest }) {
|
|
545
|
+
const { pkh } = await this.getKeys();
|
|
546
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
547
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT, gasLimit);
|
|
548
|
+
const op = await (0, contract_1.createRegisterGlobalConstantOperation)({
|
|
549
|
+
...rest,
|
|
550
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
540
551
|
});
|
|
552
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
553
|
+
const ops = this.convertIntoArray(operation);
|
|
554
|
+
const hash = await this.getBlockHash();
|
|
555
|
+
const protocol = await this.getProtocolHash();
|
|
556
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
557
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
558
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
559
|
+
const preparedOperation = {
|
|
560
|
+
opOb: {
|
|
561
|
+
branch: hash,
|
|
562
|
+
contents,
|
|
563
|
+
protocol,
|
|
564
|
+
},
|
|
565
|
+
counter: headCounter,
|
|
566
|
+
};
|
|
567
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
541
568
|
}
|
|
542
569
|
/**
|
|
543
570
|
*
|
|
544
|
-
*
|
|
545
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
571
|
+
* Method to prepare an update_consensus_key operation
|
|
546
572
|
* @param source string or undefined source pkh
|
|
547
573
|
* @returns a PreparedOperation object
|
|
548
574
|
*/
|
|
549
|
-
updateConsensusKey(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
if (!rest.proof) {
|
|
556
|
-
throw new core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
557
|
-
}
|
|
575
|
+
async updateConsensusKey({ fee, storageLimit, gasLimit, ...rest }, source) {
|
|
576
|
+
const { pkh } = await this.getKeys();
|
|
577
|
+
const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(rest.pk, utils_1.publicKeyPrefixes);
|
|
578
|
+
if (pkPrefix === utils_1.PrefixV2.BLS12_381PublicKey) {
|
|
579
|
+
if (!rest.proof) {
|
|
580
|
+
throw new core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
558
581
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
if (rest.proof) {
|
|
585
|
+
throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
563
586
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const protocol = yield this.getProtocolHash();
|
|
571
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
572
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
573
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
574
|
-
return {
|
|
575
|
-
opOb: {
|
|
576
|
-
branch: hash,
|
|
577
|
-
contents,
|
|
578
|
-
protocol,
|
|
579
|
-
},
|
|
580
|
-
counter: headCounter,
|
|
581
|
-
};
|
|
587
|
+
}
|
|
588
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
589
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.UPDATE_CONSENSUS_KEY, gasLimit);
|
|
590
|
+
const op = await (0, contract_1.createUpdateConsensusKeyOperation)({
|
|
591
|
+
...rest,
|
|
592
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
582
593
|
});
|
|
594
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
595
|
+
const ops = this.convertIntoArray(operation);
|
|
596
|
+
const hash = await this.getBlockHash();
|
|
597
|
+
const protocol = await this.getProtocolHash();
|
|
598
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
599
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
600
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
601
|
+
const preparedOperation = {
|
|
602
|
+
opOb: {
|
|
603
|
+
branch: hash,
|
|
604
|
+
contents,
|
|
605
|
+
protocol,
|
|
606
|
+
},
|
|
607
|
+
counter: headCounter,
|
|
608
|
+
};
|
|
609
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
583
610
|
}
|
|
584
611
|
/**
|
|
585
612
|
*
|
|
586
|
-
*
|
|
587
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
613
|
+
* Method to prepare an update_companion_key operation
|
|
588
614
|
* @param source string or undefined source pkh
|
|
589
615
|
* @returns a PreparedOperation object
|
|
590
616
|
*/
|
|
591
|
-
updateCompanionKey(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
606
|
-
const ops = this.convertIntoArray(operation);
|
|
607
|
-
const hash = yield this.getBlockHash();
|
|
608
|
-
const protocol = yield this.getProtocolHash();
|
|
609
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
610
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
611
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
612
|
-
return {
|
|
613
|
-
opOb: {
|
|
614
|
-
branch: hash,
|
|
615
|
-
contents,
|
|
616
|
-
protocol,
|
|
617
|
-
},
|
|
618
|
-
counter: headCounter,
|
|
619
|
-
};
|
|
617
|
+
async updateCompanionKey({ fee, storageLimit, gasLimit, ...rest }, source) {
|
|
618
|
+
const { pkh } = await this.getKeys();
|
|
619
|
+
const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(rest.pk, utils_1.publicKeyPrefixes);
|
|
620
|
+
if (pkPrefix !== utils_1.PrefixV2.BLS12_381PublicKey) {
|
|
621
|
+
throw new core_1.ProhibitedActionError('companion key must be a bls account');
|
|
622
|
+
}
|
|
623
|
+
if (!rest.proof) {
|
|
624
|
+
throw new core_1.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
625
|
+
}
|
|
626
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
627
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.UPDATE_COMPANION_KEY, gasLimit);
|
|
628
|
+
const op = await (0, contract_1.createUpdateCompanionKeyOperation)({
|
|
629
|
+
...rest,
|
|
630
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
620
631
|
});
|
|
632
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
633
|
+
const ops = this.convertIntoArray(operation);
|
|
634
|
+
const hash = await this.getBlockHash();
|
|
635
|
+
const protocol = await this.getProtocolHash();
|
|
636
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
637
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
638
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
639
|
+
const preparedOperation = {
|
|
640
|
+
opOb: {
|
|
641
|
+
branch: hash,
|
|
642
|
+
contents,
|
|
643
|
+
protocol,
|
|
644
|
+
},
|
|
645
|
+
counter: headCounter,
|
|
646
|
+
};
|
|
647
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
621
648
|
}
|
|
622
649
|
/**
|
|
623
650
|
*
|
|
624
|
-
*
|
|
625
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
626
|
-
* @param source string or undefined source pkh
|
|
651
|
+
* Method to prepare an increase_paid_storage operation
|
|
627
652
|
* @returns a PreparedOperation object
|
|
628
653
|
*/
|
|
629
|
-
increasePaidStorage(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
637
|
-
const ops = this.convertIntoArray(operation);
|
|
638
|
-
const hash = yield this.getBlockHash();
|
|
639
|
-
const protocol = yield this.getProtocolHash();
|
|
640
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
641
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
642
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
643
|
-
return {
|
|
644
|
-
opOb: {
|
|
645
|
-
branch: hash,
|
|
646
|
-
contents,
|
|
647
|
-
protocol,
|
|
648
|
-
},
|
|
649
|
-
counter: headCounter,
|
|
650
|
-
};
|
|
654
|
+
async increasePaidStorage({ fee, storageLimit, gasLimit, ...rest }) {
|
|
655
|
+
const { pkh } = await this.getKeys();
|
|
656
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
657
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.INCREASE_PAID_STORAGE, gasLimit);
|
|
658
|
+
const op = await (0, contract_1.createIncreasePaidStorageOperation)({
|
|
659
|
+
...rest,
|
|
660
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
651
661
|
});
|
|
662
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
663
|
+
const ops = this.convertIntoArray(operation);
|
|
664
|
+
const hash = await this.getBlockHash();
|
|
665
|
+
const protocol = await this.getProtocolHash();
|
|
666
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
667
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
668
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
669
|
+
const preparedOperation = {
|
|
670
|
+
opOb: {
|
|
671
|
+
branch: hash,
|
|
672
|
+
contents,
|
|
673
|
+
protocol,
|
|
674
|
+
},
|
|
675
|
+
counter: headCounter,
|
|
676
|
+
};
|
|
677
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
652
678
|
}
|
|
653
679
|
/**
|
|
654
680
|
*
|
|
655
|
-
*
|
|
656
|
-
* @param
|
|
681
|
+
* Method to prepare a ballot operation
|
|
682
|
+
* @param params ballot operation parameters
|
|
657
683
|
* @returns a PreparedOperation object
|
|
658
684
|
*/
|
|
659
|
-
ballot(params) {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
const ops = this.convertIntoArray(op);
|
|
664
|
-
const hash = yield this.getBlockHash();
|
|
665
|
-
const protocol = yield this.getProtocolHash();
|
|
666
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
667
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
668
|
-
let currentVotingPeriod;
|
|
669
|
-
try {
|
|
670
|
-
currentVotingPeriod = yield this.rpc.getCurrentPeriod();
|
|
671
|
-
}
|
|
672
|
-
catch (e) {
|
|
673
|
-
throw new errors_1.RPCResponseError('Failed to get the current voting period index');
|
|
674
|
-
}
|
|
675
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, params.source, currentVotingPeriod);
|
|
676
|
-
return {
|
|
677
|
-
opOb: {
|
|
678
|
-
branch: hash,
|
|
679
|
-
contents,
|
|
680
|
-
protocol,
|
|
681
|
-
},
|
|
682
|
-
counter: headCounter,
|
|
683
|
-
};
|
|
685
|
+
async ballot(params) {
|
|
686
|
+
const { pkh } = await this.getKeys();
|
|
687
|
+
const op = await (0, contract_1.createBallotOperation)({
|
|
688
|
+
...params,
|
|
684
689
|
});
|
|
690
|
+
const ops = this.convertIntoArray(op);
|
|
691
|
+
const hash = await this.getBlockHash();
|
|
692
|
+
const protocol = await this.getProtocolHash();
|
|
693
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
694
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
695
|
+
let currentVotingPeriod;
|
|
696
|
+
try {
|
|
697
|
+
currentVotingPeriod = await this.rpc.getCurrentPeriod();
|
|
698
|
+
}
|
|
699
|
+
catch (e) {
|
|
700
|
+
throw new errors_1.RPCResponseError('Failed to get the current voting period index');
|
|
701
|
+
}
|
|
702
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, params.source, currentVotingPeriod);
|
|
703
|
+
const preparedOperation = {
|
|
704
|
+
opOb: {
|
|
705
|
+
branch: hash,
|
|
706
|
+
contents,
|
|
707
|
+
protocol,
|
|
708
|
+
},
|
|
709
|
+
counter: headCounter,
|
|
710
|
+
};
|
|
711
|
+
return preparedOperation;
|
|
685
712
|
}
|
|
686
713
|
/**
|
|
687
714
|
*
|
|
688
|
-
*
|
|
689
|
-
* @param
|
|
715
|
+
* Method to prepare a proposals operation
|
|
716
|
+
* @param params proposals operation parameters
|
|
690
717
|
* @returns a PreparedOperation object
|
|
691
718
|
*/
|
|
692
|
-
proposals(params) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
const ops = this.convertIntoArray(op);
|
|
697
|
-
const hash = yield this.getBlockHash();
|
|
698
|
-
const protocol = yield this.getProtocolHash();
|
|
699
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
700
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
701
|
-
let currentVotingPeriod;
|
|
702
|
-
try {
|
|
703
|
-
currentVotingPeriod = yield this.rpc.getCurrentPeriod();
|
|
704
|
-
}
|
|
705
|
-
catch (e) {
|
|
706
|
-
throw new errors_1.RPCResponseError('Failed to get the current voting period index');
|
|
707
|
-
}
|
|
708
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, params.source, currentVotingPeriod);
|
|
709
|
-
return {
|
|
710
|
-
opOb: {
|
|
711
|
-
branch: hash,
|
|
712
|
-
contents,
|
|
713
|
-
protocol,
|
|
714
|
-
},
|
|
715
|
-
counter: headCounter,
|
|
716
|
-
};
|
|
719
|
+
async proposals(params) {
|
|
720
|
+
const { pkh } = await this.getKeys();
|
|
721
|
+
const op = await (0, contract_1.createProposalsOperation)({
|
|
722
|
+
...params,
|
|
717
723
|
});
|
|
724
|
+
const ops = this.convertIntoArray(op);
|
|
725
|
+
const hash = await this.getBlockHash();
|
|
726
|
+
const protocol = await this.getProtocolHash();
|
|
727
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
728
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
729
|
+
let currentVotingPeriod;
|
|
730
|
+
try {
|
|
731
|
+
currentVotingPeriod = await this.rpc.getCurrentPeriod();
|
|
732
|
+
}
|
|
733
|
+
catch (e) {
|
|
734
|
+
throw new errors_1.RPCResponseError('Failed to get the current voting period index');
|
|
735
|
+
}
|
|
736
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, params.source, currentVotingPeriod);
|
|
737
|
+
const preparedOperation = {
|
|
738
|
+
opOb: {
|
|
739
|
+
branch: hash,
|
|
740
|
+
contents,
|
|
741
|
+
protocol,
|
|
742
|
+
},
|
|
743
|
+
counter: headCounter,
|
|
744
|
+
};
|
|
745
|
+
return preparedOperation;
|
|
718
746
|
}
|
|
719
747
|
/**
|
|
720
748
|
*
|
|
721
|
-
*
|
|
722
|
-
* @param
|
|
749
|
+
* Method to prepare a drain_delegate operation
|
|
750
|
+
* @param params drainDelegate operation parameters
|
|
723
751
|
* @returns a PreparedOperation object
|
|
724
752
|
*/
|
|
725
|
-
drainDelegate(params, source) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
const ops = this.convertIntoArray(op);
|
|
730
|
-
const hash = yield this.getBlockHash();
|
|
731
|
-
const protocol = yield this.getProtocolHash();
|
|
732
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
733
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
734
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
735
|
-
return {
|
|
736
|
-
opOb: {
|
|
737
|
-
branch: hash,
|
|
738
|
-
contents,
|
|
739
|
-
protocol,
|
|
740
|
-
},
|
|
741
|
-
counter: headCounter,
|
|
742
|
-
};
|
|
753
|
+
async drainDelegate(params, source) {
|
|
754
|
+
const { pkh } = await this.getKeys();
|
|
755
|
+
const op = await (0, contract_1.createDrainDelegateOperation)({
|
|
756
|
+
...params,
|
|
743
757
|
});
|
|
758
|
+
const ops = this.convertIntoArray(op);
|
|
759
|
+
const hash = await this.getBlockHash();
|
|
760
|
+
const protocol = await this.getProtocolHash();
|
|
761
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
762
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
763
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, source);
|
|
764
|
+
const preparedOperation = {
|
|
765
|
+
opOb: {
|
|
766
|
+
branch: hash,
|
|
767
|
+
contents,
|
|
768
|
+
protocol,
|
|
769
|
+
},
|
|
770
|
+
counter: headCounter,
|
|
771
|
+
};
|
|
772
|
+
return preparedOperation;
|
|
744
773
|
}
|
|
745
774
|
/**
|
|
746
775
|
*
|
|
747
|
-
*
|
|
748
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
749
|
-
* @param source string or undefined source pkh
|
|
776
|
+
* Method to prepare a transfer_ticket operation
|
|
750
777
|
* @returns a PreparedOperation object
|
|
751
778
|
*/
|
|
752
|
-
transferTicket(
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
760
|
-
const ops = this.convertIntoArray(operation);
|
|
761
|
-
const hash = yield this.getBlockHash();
|
|
762
|
-
const protocol = yield this.getProtocolHash();
|
|
763
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
764
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
765
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
766
|
-
return {
|
|
767
|
-
opOb: {
|
|
768
|
-
branch: hash,
|
|
769
|
-
contents,
|
|
770
|
-
protocol,
|
|
771
|
-
},
|
|
772
|
-
counter: headCounter,
|
|
773
|
-
};
|
|
779
|
+
async transferTicket({ fee, storageLimit, gasLimit, ...rest }) {
|
|
780
|
+
const { pkh } = await this.getKeys();
|
|
781
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
782
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.TRANSFER_TICKET, gasLimit);
|
|
783
|
+
const op = await (0, contract_1.createTransferTicketOperation)({
|
|
784
|
+
...rest,
|
|
785
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
774
786
|
});
|
|
787
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
788
|
+
const ops = this.convertIntoArray(operation);
|
|
789
|
+
const hash = await this.getBlockHash();
|
|
790
|
+
const protocol = await this.getProtocolHash();
|
|
791
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
792
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
793
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
794
|
+
const preparedOperation = {
|
|
795
|
+
opOb: {
|
|
796
|
+
branch: hash,
|
|
797
|
+
contents,
|
|
798
|
+
protocol,
|
|
799
|
+
},
|
|
800
|
+
counter: headCounter,
|
|
801
|
+
};
|
|
802
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
775
803
|
}
|
|
776
804
|
/**
|
|
777
805
|
*
|
|
778
|
-
*
|
|
779
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
780
|
-
* @param source string or undefined source pkh
|
|
806
|
+
* Method to prepare a smart_rollup_add_messages operation
|
|
781
807
|
* @returns a PreparedOperation object
|
|
782
808
|
*/
|
|
783
|
-
smartRollupAddMessages(
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
791
|
-
const ops = this.convertIntoArray(operation);
|
|
792
|
-
const hash = yield this.getBlockHash();
|
|
793
|
-
const protocol = yield this.getProtocolHash();
|
|
794
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
795
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
796
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
797
|
-
return {
|
|
798
|
-
opOb: {
|
|
799
|
-
branch: hash,
|
|
800
|
-
contents,
|
|
801
|
-
protocol,
|
|
802
|
-
},
|
|
803
|
-
counter: headCounter,
|
|
804
|
-
};
|
|
809
|
+
async smartRollupAddMessages({ fee, storageLimit, gasLimit, ...rest }) {
|
|
810
|
+
const { pkh } = await this.getKeys();
|
|
811
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
812
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES, gasLimit);
|
|
813
|
+
const op = await (0, contract_1.createSmartRollupAddMessagesOperation)({
|
|
814
|
+
...rest,
|
|
815
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
805
816
|
});
|
|
817
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
818
|
+
const ops = this.convertIntoArray(operation);
|
|
819
|
+
const hash = await this.getBlockHash();
|
|
820
|
+
const protocol = await this.getProtocolHash();
|
|
821
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
822
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
823
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
824
|
+
const preparedOperation = {
|
|
825
|
+
opOb: {
|
|
826
|
+
branch: hash,
|
|
827
|
+
contents,
|
|
828
|
+
protocol,
|
|
829
|
+
},
|
|
830
|
+
counter: headCounter,
|
|
831
|
+
};
|
|
832
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
806
833
|
}
|
|
807
834
|
/**
|
|
808
835
|
*
|
|
809
|
-
*
|
|
810
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
836
|
+
* Method to prepare a smart_rollup_originate operation
|
|
811
837
|
* @returns a PreparedOperation object
|
|
812
838
|
*/
|
|
813
|
-
smartRollupOriginate(
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
821
|
-
const ops = this.convertIntoArray(operation);
|
|
822
|
-
const hash = yield this.getBlockHash();
|
|
823
|
-
const protocol = yield this.getProtocolHash();
|
|
824
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
825
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
826
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
827
|
-
return {
|
|
828
|
-
opOb: {
|
|
829
|
-
branch: hash,
|
|
830
|
-
contents,
|
|
831
|
-
protocol,
|
|
832
|
-
},
|
|
833
|
-
counter: headCounter,
|
|
834
|
-
};
|
|
839
|
+
async smartRollupOriginate({ fee, storageLimit, gasLimit, ...rest }) {
|
|
840
|
+
const { pkh } = await this.getKeys();
|
|
841
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
842
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.SMART_ROLLUP_ORIGINATE, gasLimit);
|
|
843
|
+
const op = await (0, contract_1.createSmartRollupOriginateOperation)({
|
|
844
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
845
|
+
...rest,
|
|
835
846
|
});
|
|
847
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
848
|
+
const ops = this.convertIntoArray(operation);
|
|
849
|
+
const hash = await this.getBlockHash();
|
|
850
|
+
const protocol = await this.getProtocolHash();
|
|
851
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
852
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
853
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
854
|
+
const preparedOperation = {
|
|
855
|
+
opOb: {
|
|
856
|
+
branch: hash,
|
|
857
|
+
contents,
|
|
858
|
+
protocol,
|
|
859
|
+
},
|
|
860
|
+
counter: headCounter,
|
|
861
|
+
};
|
|
862
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
836
863
|
}
|
|
837
864
|
/**
|
|
838
865
|
*
|
|
839
|
-
*
|
|
840
|
-
* @param operation RPCOperation object or RPCOperation array
|
|
841
|
-
* @param source string or undefined source pkh
|
|
866
|
+
* Method to prepare a smart_rollup_execute_outbox_message operation
|
|
842
867
|
* @returns a PreparedOperation object
|
|
843
868
|
*/
|
|
844
|
-
smartRollupExecuteOutboxMessage(
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
const operation = yield this.addRevealOperationIfNeeded(op, pkh);
|
|
852
|
-
const ops = this.convertIntoArray(operation);
|
|
853
|
-
const hash = yield this.getBlockHash();
|
|
854
|
-
const protocol = yield this.getProtocolHash();
|
|
855
|
-
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
856
|
-
const headCounter = parseInt(yield this.getHeadCounter(pkh), 10);
|
|
857
|
-
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
858
|
-
return {
|
|
859
|
-
opOb: {
|
|
860
|
-
branch: hash,
|
|
861
|
-
contents,
|
|
862
|
-
protocol,
|
|
863
|
-
},
|
|
864
|
-
counter: headCounter,
|
|
865
|
-
};
|
|
869
|
+
async smartRollupExecuteOutboxMessage({ fee, storageLimit, gasLimit, ...rest }) {
|
|
870
|
+
const { pkh } = await this.getKeys();
|
|
871
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
872
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE, gasLimit);
|
|
873
|
+
const op = await (0, contract_1.createSmartRollupExecuteOutboxMessageOperation)({
|
|
874
|
+
...rest,
|
|
875
|
+
...mergeLimits({ fee, storageLimit, gasLimit }, DEFAULT_PARAMS),
|
|
866
876
|
});
|
|
877
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
878
|
+
const ops = this.convertIntoArray(operation);
|
|
879
|
+
const hash = await this.getBlockHash();
|
|
880
|
+
const protocol = await this.getProtocolHash();
|
|
881
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
882
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
883
|
+
const contents = this.constructOpContents(ops, headCounter, pkh, rest.source);
|
|
884
|
+
const preparedOperation = {
|
|
885
|
+
opOb: {
|
|
886
|
+
branch: hash,
|
|
887
|
+
contents,
|
|
888
|
+
protocol,
|
|
889
|
+
},
|
|
890
|
+
counter: headCounter,
|
|
891
|
+
};
|
|
892
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, gasLimit));
|
|
867
893
|
}
|
|
868
894
|
/**
|
|
869
895
|
*
|
|
870
|
-
*
|
|
871
|
-
* @param
|
|
896
|
+
* Method to prepare a batch operation
|
|
897
|
+
* @param batchParams batch operation parameters
|
|
872
898
|
* @returns a PreparedOperation object
|
|
873
899
|
*/
|
|
874
|
-
batch(batchParams, estimates) {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
}
|
|
900
|
+
async batch(batchParams, estimates) {
|
|
901
|
+
const { pkh, publicKey } = await this.getKeys();
|
|
902
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
903
|
+
const revealNeeded = await this.isRevealOpNeeded(batchParams, pkh);
|
|
904
|
+
const explicitGasLimitTotal = batchParams.reduce((acc, op) => (0, types_1.isOpWithFee)(op) && typeof op.gasLimit !== 'undefined' ? acc.plus(op.gasLimit) : acc, revealNeeded ? new bignumber_js_1.default((0, constants_1.getRevealGasLimit)(pkh)) : new bignumber_js_1.default(0));
|
|
905
|
+
const DEFAULT_PARAMS = this.getOperationLimits(protocolConstants, {
|
|
906
|
+
opsNeedingGasLimitPatch: batchParams.filter((op) => (0, types_1.isOpWithFee)(op) && typeof op.gasLimit === 'undefined').length,
|
|
907
|
+
explicitGasLimitTotal,
|
|
908
|
+
});
|
|
909
|
+
const ops = [];
|
|
910
|
+
const gasLimitPatchableFlags = [];
|
|
911
|
+
if (!estimates) {
|
|
912
|
+
for (const op of batchParams) {
|
|
913
|
+
if ((0, types_1.isOpWithFee)(op)) {
|
|
914
|
+
const limits = mergeLimits(op, DEFAULT_PARAMS);
|
|
915
|
+
ops.push(await this.getRPCOp({ ...op, ...limits }));
|
|
916
|
+
gasLimitPatchableFlags.push(typeof op.gasLimit === 'undefined');
|
|
890
917
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
if ((0, types_1.isOpWithFee)(op)) {
|
|
895
|
-
const e = estimates.shift();
|
|
896
|
-
const limits = mergeLimits(op, {
|
|
897
|
-
fee: e.suggestedFeeMutez,
|
|
898
|
-
storageLimit: e.storageLimit,
|
|
899
|
-
gasLimit: e.gasLimit,
|
|
900
|
-
});
|
|
901
|
-
ops.push(yield this.getRPCOp(Object.assign(Object.assign({}, op), limits)));
|
|
902
|
-
}
|
|
903
|
-
else {
|
|
904
|
-
ops.push(Object.assign({}, op));
|
|
905
|
-
}
|
|
918
|
+
else {
|
|
919
|
+
ops.push({ ...op });
|
|
920
|
+
gasLimitPatchableFlags.push(false);
|
|
906
921
|
}
|
|
907
922
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
923
|
+
}
|
|
924
|
+
else {
|
|
925
|
+
for (const op of batchParams) {
|
|
926
|
+
if ((0, types_1.isOpWithFee)(op)) {
|
|
927
|
+
const e = estimates.shift();
|
|
928
|
+
const limits = mergeLimits(op, {
|
|
929
|
+
fee: e.suggestedFeeMutez,
|
|
930
|
+
storageLimit: e.storageLimit,
|
|
931
|
+
gasLimit: e.gasLimit,
|
|
932
|
+
});
|
|
933
|
+
ops.push(await this.getRPCOp({ ...op, ...limits }));
|
|
934
|
+
gasLimitPatchableFlags.push(false);
|
|
935
|
+
}
|
|
936
|
+
else {
|
|
937
|
+
ops.push({ ...op });
|
|
938
|
+
gasLimitPatchableFlags.push(false);
|
|
911
939
|
}
|
|
912
|
-
const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(pkh, utils_1.publicKeyHashPrefixes);
|
|
913
|
-
ops.unshift(yield (0, contract_1.createRevealOperation)({
|
|
914
|
-
fee: (0, constants_1.getRevealFee)(pkh),
|
|
915
|
-
storageLimit: constants_1.REVEAL_STORAGE_LIMIT,
|
|
916
|
-
gasLimit: (0, constants_1.getRevealGasLimit)(pkh),
|
|
917
|
-
proof: pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash
|
|
918
|
-
? (yield this.signer.provePossession()).prefixSig
|
|
919
|
-
: undefined,
|
|
920
|
-
}, pkh, publicKey));
|
|
921
940
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
941
|
+
}
|
|
942
|
+
if (revealNeeded) {
|
|
943
|
+
if (!publicKey) {
|
|
944
|
+
throw new core_1.PublicKeyNotFoundError(pkh);
|
|
945
|
+
}
|
|
946
|
+
const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(pkh, utils_1.publicKeyHashPrefixes);
|
|
947
|
+
ops.unshift(await (0, contract_1.createRevealOperation)({
|
|
948
|
+
fee: (0, constants_1.getRevealFee)(pkh),
|
|
949
|
+
storageLimit: constants_1.REVEAL_STORAGE_LIMIT,
|
|
950
|
+
gasLimit: (0, constants_1.getRevealGasLimit)(pkh),
|
|
951
|
+
proof: pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash
|
|
952
|
+
? (await this.signer.provePossession()).prefixSig
|
|
953
|
+
: undefined,
|
|
954
|
+
}, pkh, publicKey));
|
|
955
|
+
gasLimitPatchableFlags.unshift(false);
|
|
956
|
+
}
|
|
957
|
+
const hash = await this.getBlockHash();
|
|
958
|
+
const protocol = await this.getProtocolHash();
|
|
959
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
960
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
961
|
+
const contents = this.constructOpContents(ops, headCounter, pkh);
|
|
962
|
+
const gasLimitPatchableIndexes = gasLimitPatchableFlags.flatMap((isPatchable, index) => isPatchable ? [index] : []);
|
|
963
|
+
return {
|
|
964
|
+
opOb: {
|
|
965
|
+
branch: hash,
|
|
966
|
+
contents,
|
|
967
|
+
protocol,
|
|
968
|
+
},
|
|
969
|
+
counter: headCounter,
|
|
970
|
+
simulation: gasLimitPatchableIndexes.length > 0
|
|
971
|
+
? {
|
|
972
|
+
gasLimitPatchableIndexes,
|
|
973
|
+
}
|
|
974
|
+
: undefined,
|
|
975
|
+
};
|
|
936
976
|
}
|
|
937
977
|
/**
|
|
938
978
|
*
|
|
939
|
-
*
|
|
940
|
-
* @param
|
|
979
|
+
* Method to prepare a contract call operation
|
|
980
|
+
* @param contractMethod ContractMethodObject retrieved from smart contract
|
|
941
981
|
* @returns a PreparedOperation object
|
|
942
982
|
*/
|
|
943
|
-
contractCall(contractMethod) {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
};
|
|
979
|
-
});
|
|
983
|
+
async contractCall(contractMethod) {
|
|
984
|
+
const hash = await this.getBlockHash();
|
|
985
|
+
const protocol = await this.getProtocolHash();
|
|
986
|
+
const { pkh } = await this.getKeys();
|
|
987
|
+
__classPrivateFieldSet(this, _PrepareProvider_counters, {}, "f");
|
|
988
|
+
const headCounter = parseInt(await this.getHeadCounter(pkh), 10);
|
|
989
|
+
const params = contractMethod.toTransferParams();
|
|
990
|
+
const protocolConstants = await this.context.readProvider.getProtocolConstants('head');
|
|
991
|
+
const DEFAULT_PARAMS = await this.getOperationLimitsForManagerOperation(protocolConstants, pkh, rpc_1.OpKind.TRANSACTION, params.gasLimit);
|
|
992
|
+
const estimateLimits = mergeLimits({
|
|
993
|
+
fee: params.fee,
|
|
994
|
+
storageLimit: params.storageLimit,
|
|
995
|
+
gasLimit: params.gasLimit,
|
|
996
|
+
}, DEFAULT_PARAMS);
|
|
997
|
+
const op = {
|
|
998
|
+
kind: rpc_1.OpKind.TRANSACTION,
|
|
999
|
+
fee: params.fee ?? estimateLimits.fee,
|
|
1000
|
+
gas_limit: params.gasLimit ?? estimateLimits.gasLimit,
|
|
1001
|
+
storage_limit: params.storageLimit ?? estimateLimits.storageLimit,
|
|
1002
|
+
amount: String(params.amount),
|
|
1003
|
+
destination: params.to,
|
|
1004
|
+
parameters: params.parameter,
|
|
1005
|
+
};
|
|
1006
|
+
const operation = await this.addRevealOperationIfNeeded(op, pkh);
|
|
1007
|
+
const ops = this.convertIntoArray(operation);
|
|
1008
|
+
const contents = this.constructOpContents(ops, headCounter, pkh);
|
|
1009
|
+
const preparedOperation = {
|
|
1010
|
+
opOb: {
|
|
1011
|
+
branch: hash,
|
|
1012
|
+
contents,
|
|
1013
|
+
protocol,
|
|
1014
|
+
},
|
|
1015
|
+
counter: headCounter,
|
|
1016
|
+
};
|
|
1017
|
+
return this.withSimulationMetadata(preparedOperation, this.getSingleManagerOperationSimulation(ops, params.gasLimit));
|
|
980
1018
|
}
|
|
981
1019
|
/**
|
|
982
1020
|
*
|
|
983
|
-
*
|
|
1021
|
+
* Method to convert a PreparedOperation to the params needed for the preapplyOperation method
|
|
984
1022
|
* @param prepared a Prepared Operation
|
|
985
1023
|
* @returns a PreapplyParams object
|
|
986
1024
|
*/
|
|
987
|
-
toPreapply(prepared) {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
return [{ contents, branch, protocol, signature: sig.prefixSig }];
|
|
994
|
-
});
|
|
1025
|
+
async toPreapply(prepared) {
|
|
1026
|
+
const { opOb: { contents, branch, protocol }, } = prepared;
|
|
1027
|
+
const forgeParams = this.toForge(prepared);
|
|
1028
|
+
const forged = await this.context.forger.forge(forgeParams);
|
|
1029
|
+
const sig = await this.context.signer.sign(forged, new Uint8Array([3]));
|
|
1030
|
+
return [{ contents, branch, protocol, signature: sig.prefixSig }];
|
|
995
1031
|
}
|
|
996
1032
|
/**
|
|
997
1033
|
*
|
|
998
|
-
*
|
|
1034
|
+
* Method to convert a PreparedOperation to the params needed for forging
|
|
999
1035
|
* @param param a Prepared Operation
|
|
1000
1036
|
* @returns a ForgeParams object
|
|
1001
1037
|
*/
|