@taquito/taquito 23.0.0-beta.0 → 23.0.0-beta.1
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 +47 -5
- package/dist/lib/constants.js +1 -2
- package/dist/lib/contract/contract.js +1 -1
- package/dist/lib/contract/prepare.js +17 -3
- package/dist/lib/contract/rpc-contract-provider.js +67 -17
- package/dist/lib/estimate/rpc-estimate-provider.js +133 -27
- package/dist/lib/operations/index.js +3 -1
- package/dist/lib/operations/reveal-operation.js +9 -0
- package/dist/lib/operations/types.js +5 -1
- package/dist/lib/operations/update-companion-key-operation.js +58 -0
- package/dist/lib/operations/update-consensus-key-operation.js +9 -0
- package/dist/lib/prepare/prepare-provider.js +76 -3
- package/dist/lib/provider.js +4 -0
- package/dist/lib/tz/rpc-tz-provider.js +4 -4
- package/dist/lib/version.js +2 -2
- package/dist/lib/wallet/wallet.js +9 -9
- package/dist/taquito.es6.js +434 -76
- package/dist/taquito.es6.js.map +1 -1
- package/dist/taquito.min.js +1 -1
- package/dist/taquito.min.js.LICENSE.txt +2 -0
- package/dist/taquito.umd.js +433 -73
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/batch/rpc-batch-provider.d.ts +16 -2
- package/dist/types/contract/interface.d.ts +10 -3
- package/dist/types/contract/prepare.d.ts +4 -3
- package/dist/types/contract/rpc-contract-provider.d.ts +11 -4
- package/dist/types/estimate/estimate-provider-interface.d.ts +9 -3
- package/dist/types/estimate/rpc-estimate-provider.d.ts +10 -4
- package/dist/types/operations/index.d.ts +1 -0
- package/dist/types/operations/reveal-operation.d.ts +1 -0
- package/dist/types/operations/types.d.ts +26 -5
- package/dist/types/operations/update-companion-key-operation.d.ts +23 -0
- package/dist/types/operations/update-consensus-key-operation.d.ts +1 -0
- package/dist/types/prepare/interface.d.ts +8 -3
- package/dist/types/prepare/prepare-provider.d.ts +10 -4
- package/dist/types/provider.d.ts +1 -1
- package/dist/types/signer/interface.d.ts +18 -8
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The `@taquito/taquito` package contains higher-level functionality that builds u
|
|
|
7
7
|
## CDN Bundle
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
|
-
<script src="https://unpkg.com/@taquito/taquito@23.0.0-beta.
|
|
10
|
+
<script src="https://unpkg.com/@taquito/taquito@23.0.0-beta.1/dist/taquito.min.js"
|
|
11
11
|
crossorigin="anonymous" integrity="sha384-IxvP0ECHi5oqLyz94wF85pU9+ktcsL1HHtA42MITxZsGbsUMEu/g+0Vkjj5vqiMR"></script>
|
|
12
12
|
```
|
|
13
13
|
|
|
@@ -42,7 +42,7 @@ class OperationBatch extends provider_1.Provider {
|
|
|
42
42
|
throw new core_1.InvalidAmountError(params.amount.toString());
|
|
43
43
|
}
|
|
44
44
|
if (toValidation !== utils_1.ValidationResult.VALID) {
|
|
45
|
-
throw new core_1.InvalidAddressError(params.to,
|
|
45
|
+
throw new core_1.InvalidAddressError(params.to, toValidation);
|
|
46
46
|
}
|
|
47
47
|
this.operations.push(Object.assign({ kind: rpc_1.OpKind.TRANSACTION }, params));
|
|
48
48
|
return this;
|
|
@@ -56,7 +56,7 @@ class OperationBatch extends provider_1.Provider {
|
|
|
56
56
|
withTransferTicket(params) {
|
|
57
57
|
const destinationValidation = (0, utils_1.validateAddress)(params.destination);
|
|
58
58
|
if (destinationValidation !== utils_1.ValidationResult.VALID) {
|
|
59
|
-
throw new core_1.InvalidAddressError(params.destination,
|
|
59
|
+
throw new core_1.InvalidAddressError(params.destination, destinationValidation);
|
|
60
60
|
}
|
|
61
61
|
this.operations.push(Object.assign({ kind: rpc_1.OpKind.TRANSFER_TICKET }, params));
|
|
62
62
|
return this;
|
|
@@ -81,11 +81,11 @@ class OperationBatch extends provider_1.Provider {
|
|
|
81
81
|
var _a;
|
|
82
82
|
const sourceValidation = (0, utils_1.validateAddress)(params.source);
|
|
83
83
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
84
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
84
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
85
85
|
}
|
|
86
86
|
const delegateValidation = (0, utils_1.validateAddress)((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
87
87
|
if (params.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
|
|
88
|
-
throw new core_1.InvalidAddressError(params.delegate,
|
|
88
|
+
throw new core_1.InvalidAddressError(params.delegate, delegateValidation);
|
|
89
89
|
}
|
|
90
90
|
this.operations.push(Object.assign({ kind: rpc_1.OpKind.DELEGATION }, params));
|
|
91
91
|
return this;
|
|
@@ -100,7 +100,7 @@ class OperationBatch extends provider_1.Provider {
|
|
|
100
100
|
withActivation({ pkh, secret }) {
|
|
101
101
|
const pkhValidation = (0, utils_1.validateKeyHash)(pkh);
|
|
102
102
|
if (pkhValidation !== utils_1.ValidationResult.VALID) {
|
|
103
|
-
throw new core_1.InvalidKeyHashError(pkh,
|
|
103
|
+
throw new core_1.InvalidKeyHashError(pkh, pkhValidation);
|
|
104
104
|
}
|
|
105
105
|
this.operations.push({ kind: rpc_1.OpKind.ACTIVATION, pkh, secret });
|
|
106
106
|
return this;
|
|
@@ -135,6 +135,44 @@ class OperationBatch extends provider_1.Provider {
|
|
|
135
135
|
this.operations.push(Object.assign({ kind: rpc_1.OpKind.INCREASE_PAID_STORAGE }, params));
|
|
136
136
|
return this;
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @description Add a update consensus key operation to the batch
|
|
141
|
+
*
|
|
142
|
+
* @param params UpdateConsensusKey operation parameter
|
|
143
|
+
*/
|
|
144
|
+
withUpdateConsensusKey(params) {
|
|
145
|
+
const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
|
|
146
|
+
if (pkPrefix === utils_1.PrefixV2.BLS12_381PublicKey) {
|
|
147
|
+
if (!params.proof) {
|
|
148
|
+
throw new core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
if (params.proof) {
|
|
153
|
+
throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
this.operations.push(Object.assign({ kind: rpc_1.OpKind.UPDATE_CONSENSUS_KEY }, params));
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
*
|
|
161
|
+
* @description Add a update companion key operation to the batch
|
|
162
|
+
*
|
|
163
|
+
* @param params UpdateCompanionKey operation parameter
|
|
164
|
+
*/
|
|
165
|
+
withUpdateCompanionKey(params) {
|
|
166
|
+
const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
|
|
167
|
+
if (pkPrefix !== utils_1.PrefixV2.BLS12_381PublicKey) {
|
|
168
|
+
throw new core_1.ProhibitedActionError('companion key must be a bls account');
|
|
169
|
+
}
|
|
170
|
+
if (!params.proof) {
|
|
171
|
+
throw new core_1.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
172
|
+
}
|
|
173
|
+
this.operations.push(Object.assign({ kind: rpc_1.OpKind.UPDATE_COMPANION_KEY }, params));
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
138
176
|
/**
|
|
139
177
|
*
|
|
140
178
|
* @description Add a smart rollup add messages operation to the batch
|
|
@@ -178,6 +216,10 @@ class OperationBatch extends provider_1.Provider {
|
|
|
178
216
|
return (0, prepare_1.createRegisterGlobalConstantOperation)(Object.assign({}, param));
|
|
179
217
|
case rpc_1.OpKind.INCREASE_PAID_STORAGE:
|
|
180
218
|
return (0, prepare_1.createIncreasePaidStorageOperation)(Object.assign({}, param));
|
|
219
|
+
case rpc_1.OpKind.UPDATE_CONSENSUS_KEY:
|
|
220
|
+
return (0, prepare_1.createUpdateConsensusKeyOperation)(Object.assign({}, param));
|
|
221
|
+
case rpc_1.OpKind.UPDATE_COMPANION_KEY:
|
|
222
|
+
return (0, prepare_1.createUpdateCompanionKeyOperation)(Object.assign({}, param));
|
|
181
223
|
case rpc_1.OpKind.TRANSFER_TICKET:
|
|
182
224
|
return (0, prepare_1.createTransferTicketOperation)(Object.assign({}, param));
|
|
183
225
|
case rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES:
|
package/dist/lib/constants.js
CHANGED
|
@@ -124,7 +124,6 @@ var ChainIds;
|
|
|
124
124
|
ChainIds["RIONET"] = "NetXPdgaoabtBth";
|
|
125
125
|
ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
|
|
126
126
|
})(ChainIds || (exports.ChainIds = ChainIds = {}));
|
|
127
|
-
// A fixed fee reveal operation gasLimit accepted by both simulate and injection endpoint is between 1.2-5 times of actual gas consumption (3.5 fails occasionally with gas exhausted; 4 fails occasionally with fee too low)
|
|
128
127
|
const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
|
|
129
128
|
exports.getRevealGasLimit = getRevealGasLimit;
|
|
130
129
|
const getRevealGasLimitInternal = (address) => {
|
|
@@ -152,7 +151,7 @@ const getRevealFeeInternal = (address) => {
|
|
|
152
151
|
case 'tz3':
|
|
153
152
|
return REVEAL_FEE.TZ3;
|
|
154
153
|
case 'tz4':
|
|
155
|
-
return REVEAL_FEE.TZ4;
|
|
154
|
+
return REVEAL_FEE.TZ4 * 1.7;
|
|
156
155
|
default:
|
|
157
156
|
throw new Error(`Cannot estimate reveal fee for ${address}`);
|
|
158
157
|
}
|
|
@@ -36,7 +36,7 @@ class ContractView {
|
|
|
36
36
|
throw new core_1.DeprecationError(`Since version 12, the lambda view no longer depends on a lambda contract. The read method no longer accepts a contract address as a parameter.`);
|
|
37
37
|
}
|
|
38
38
|
else if (chainId && chainIdValidation !== utils_1.ValidationResult.VALID) {
|
|
39
|
-
throw new core_1.InvalidChainIdError(chainId,
|
|
39
|
+
throw new core_1.InvalidChainIdError(chainId, chainIdValidation);
|
|
40
40
|
}
|
|
41
41
|
const arg = this.parameterSchema.Encode(...this.args);
|
|
42
42
|
const result = yield this.rpc.runView({
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createSmartRollupExecuteOutboxMessageOperation = exports.createSmartRollupOriginateOperation = exports.createSmartRollupAddMessagesOperation = exports.createUpdateConsensusKeyOperation = exports.createProposalsOperation = exports.createBallotOperation = exports.createDrainDelegateOperation = exports.createIncreasePaidStorageOperation = exports.createTransferTicketOperation = exports.createRegisterGlobalConstantOperation = exports.createRevealOperation = exports.createRegisterDelegateOperation = exports.createSetDelegateOperation = exports.createTransferOperation = exports.createOriginationOperation = exports.createActivationOperation = void 0;
|
|
12
|
+
exports.createSmartRollupExecuteOutboxMessageOperation = exports.createSmartRollupOriginateOperation = exports.createSmartRollupAddMessagesOperation = exports.createUpdateCompanionKeyOperation = exports.createUpdateConsensusKeyOperation = exports.createProposalsOperation = exports.createBallotOperation = exports.createDrainDelegateOperation = exports.createIncreasePaidStorageOperation = exports.createTransferTicketOperation = exports.createRegisterGlobalConstantOperation = exports.createRevealOperation = exports.createRegisterDelegateOperation = exports.createSetDelegateOperation = exports.createTransferOperation = exports.createOriginationOperation = exports.createActivationOperation = void 0;
|
|
13
13
|
const michelson_encoder_1 = require("@taquito/michelson-encoder");
|
|
14
14
|
const rpc_1 = require("@taquito/rpc");
|
|
15
15
|
const constants_1 = require("../constants");
|
|
@@ -100,7 +100,7 @@ const createRegisterDelegateOperation = (_a, source_1) => __awaiter(void 0, [_a,
|
|
|
100
100
|
};
|
|
101
101
|
});
|
|
102
102
|
exports.createRegisterDelegateOperation = createRegisterDelegateOperation;
|
|
103
|
-
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit }, source, publicKey) {
|
|
103
|
+
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit, proof }, source, publicKey) {
|
|
104
104
|
return {
|
|
105
105
|
kind: rpc_1.OpKind.REVEAL,
|
|
106
106
|
fee,
|
|
@@ -108,6 +108,7 @@ const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [
|
|
|
108
108
|
source,
|
|
109
109
|
gas_limit: gasLimit !== null && gasLimit !== void 0 ? gasLimit : (0, constants_1.getRevealGasLimit)(source),
|
|
110
110
|
storage_limit: storageLimit,
|
|
111
|
+
proof,
|
|
111
112
|
};
|
|
112
113
|
});
|
|
113
114
|
exports.createRevealOperation = createRevealOperation;
|
|
@@ -176,7 +177,7 @@ const createProposalsOperation = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
176
177
|
};
|
|
177
178
|
});
|
|
178
179
|
exports.createProposalsOperation = createProposalsOperation;
|
|
179
|
-
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, }) {
|
|
180
|
+
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
180
181
|
return {
|
|
181
182
|
kind: rpc_1.OpKind.UPDATE_CONSENSUS_KEY,
|
|
182
183
|
source,
|
|
@@ -184,9 +185,22 @@ const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0
|
|
|
184
185
|
gas_limit: gasLimit,
|
|
185
186
|
storage_limit: storageLimit,
|
|
186
187
|
pk,
|
|
188
|
+
proof,
|
|
187
189
|
};
|
|
188
190
|
});
|
|
189
191
|
exports.createUpdateConsensusKeyOperation = createUpdateConsensusKeyOperation;
|
|
192
|
+
const createUpdateCompanionKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
193
|
+
return {
|
|
194
|
+
kind: rpc_1.OpKind.UPDATE_COMPANION_KEY,
|
|
195
|
+
source,
|
|
196
|
+
fee,
|
|
197
|
+
gas_limit: gasLimit,
|
|
198
|
+
storage_limit: storageLimit,
|
|
199
|
+
pk,
|
|
200
|
+
proof,
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
exports.createUpdateCompanionKeyOperation = createUpdateCompanionKeyOperation;
|
|
190
204
|
const createSmartRollupAddMessagesOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, message, }) {
|
|
191
205
|
return {
|
|
192
206
|
kind: rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES,
|
|
@@ -30,6 +30,7 @@ const ballot_operation_1 = require("../operations/ballot-operation");
|
|
|
30
30
|
const drain_delegate_operation_1 = require("../operations/drain-delegate-operation");
|
|
31
31
|
const proposals_operation_1 = require("../operations/proposals-operation");
|
|
32
32
|
const update_consensus_key_operation_1 = require("../operations/update-consensus-key-operation");
|
|
33
|
+
const update_companion_key_operation_1 = require("../operations/update-companion-key-operation");
|
|
33
34
|
const smart_rollup_add_messages_operation_1 = require("../operations/smart-rollup-add-messages-operation");
|
|
34
35
|
const smart_rollup_originate_operation_1 = require("../operations/smart-rollup-originate-operation");
|
|
35
36
|
const smart_rollup_execute_outbox_message_operation_1 = require("../operations/smart-rollup-execute-outbox-message-operation");
|
|
@@ -55,7 +56,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
55
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
57
|
const contractValidation = (0, utils_1.validateContractAddress)(contract);
|
|
57
58
|
if (contractValidation !== utils_1.ValidationResult.VALID) {
|
|
58
|
-
throw new core_1.InvalidContractAddressError(contract,
|
|
59
|
+
throw new core_1.InvalidContractAddressError(contract, contractValidation);
|
|
59
60
|
}
|
|
60
61
|
const script = yield this.context.readProvider.getScript(contract, 'head');
|
|
61
62
|
if (!schema) {
|
|
@@ -87,7 +88,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
87
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
89
|
const contractValidation = (0, utils_1.validateContractAddress)(contract);
|
|
89
90
|
if (contractValidation !== utils_1.ValidationResult.VALID) {
|
|
90
|
-
throw new core_1.InvalidContractAddressError(contract,
|
|
91
|
+
throw new core_1.InvalidContractAddressError(contract, contractValidation);
|
|
91
92
|
}
|
|
92
93
|
if (!schema) {
|
|
93
94
|
schema = (yield this.rpc.getContract(contract)).script;
|
|
@@ -231,11 +232,11 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
231
232
|
var _a;
|
|
232
233
|
const sourceValidation = (0, utils_1.validateAddress)(params.source);
|
|
233
234
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
234
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
235
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
235
236
|
}
|
|
236
237
|
const delegateValidation = (0, utils_1.validateAddress)((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
|
|
237
238
|
if (params.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
|
|
238
|
-
throw new core_1.InvalidAddressError(params.delegate,
|
|
239
|
+
throw new core_1.InvalidAddressError(params.delegate, delegateValidation);
|
|
239
240
|
}
|
|
240
241
|
// Since babylon delegation source cannot smart contract
|
|
241
242
|
if (/^kt1/i.test(params.source)) {
|
|
@@ -283,11 +284,11 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
283
284
|
var _a;
|
|
284
285
|
const toValidation = (0, utils_1.validateAddress)(params.to);
|
|
285
286
|
if (toValidation !== utils_1.ValidationResult.VALID) {
|
|
286
|
-
throw new core_1.InvalidAddressError(params.to,
|
|
287
|
+
throw new core_1.InvalidAddressError(params.to, toValidation);
|
|
287
288
|
}
|
|
288
289
|
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
289
290
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
290
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
291
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
291
292
|
}
|
|
292
293
|
if (params.amount < 0) {
|
|
293
294
|
throw new core_1.InvalidAmountError(params.amount.toString());
|
|
@@ -315,7 +316,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
315
316
|
var _a;
|
|
316
317
|
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
317
318
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
318
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
319
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
319
320
|
}
|
|
320
321
|
if (!params.to) {
|
|
321
322
|
params.to = params.source;
|
|
@@ -351,7 +352,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
351
352
|
var _a;
|
|
352
353
|
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
353
354
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
354
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
355
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
355
356
|
}
|
|
356
357
|
if (!params.to) {
|
|
357
358
|
params.to = params.source;
|
|
@@ -384,7 +385,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
384
385
|
var _a;
|
|
385
386
|
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
386
387
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
387
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
388
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
388
389
|
}
|
|
389
390
|
if (!params.to) {
|
|
390
391
|
params.to = params.source;
|
|
@@ -418,11 +419,11 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
418
419
|
var _a, _b;
|
|
419
420
|
const destinationValidation = (0, utils_1.validateAddress)(params.destination);
|
|
420
421
|
if (destinationValidation !== utils_1.ValidationResult.VALID) {
|
|
421
|
-
throw new core_1.InvalidAddressError(params.destination,
|
|
422
|
+
throw new core_1.InvalidAddressError(params.destination, destinationValidation);
|
|
422
423
|
}
|
|
423
424
|
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
424
425
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
425
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
426
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
426
427
|
}
|
|
427
428
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
428
429
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
@@ -437,7 +438,6 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
437
438
|
/**
|
|
438
439
|
*
|
|
439
440
|
* @description Reveal the public key of the current address. Will throw an error if the address is already revealed.
|
|
440
|
-
* @remarks Reveal tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
441
441
|
* @returns An operation handle with the result from the rpc node
|
|
442
442
|
*
|
|
443
443
|
* @param RevealParams operation parameter
|
|
@@ -445,6 +445,21 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
445
445
|
reveal(params) {
|
|
446
446
|
return __awaiter(this, void 0, void 0, function* () {
|
|
447
447
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
448
|
+
const [, pkhPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(publicKeyHash, utils_1.publicKeyHashPrefixes);
|
|
449
|
+
if (pkhPrefix === utils_1.PrefixV2.BLS12_381PublicKeyHash) {
|
|
450
|
+
if (params.proof) {
|
|
451
|
+
(0, utils_1.b58DecodeAndCheckPrefix)(params.proof, [utils_1.PrefixV2.BLS12_381Signature]); // validate proof to be a bls signature
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
const { prefixSig } = yield this.signer.provePossession();
|
|
455
|
+
params.proof = prefixSig;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
if (params.proof) {
|
|
460
|
+
throw new core_1.ProhibitedActionError('Proof field is only allowed to reveal a bls account ');
|
|
461
|
+
}
|
|
462
|
+
}
|
|
448
463
|
const estimateReveal = yield this.estimator.reveal(params);
|
|
449
464
|
if (estimateReveal) {
|
|
450
465
|
const estimated = yield this.estimate(params, () => __awaiter(this, void 0, void 0, function* () { return estimateReveal; }));
|
|
@@ -531,7 +546,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
531
546
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
532
547
|
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
533
548
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
534
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
549
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
535
550
|
}
|
|
536
551
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
537
552
|
const prepared = yield this.prepare.ballot(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -555,7 +570,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
555
570
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
556
571
|
const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
|
|
557
572
|
if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
|
|
558
|
-
throw new core_1.InvalidAddressError(params.source,
|
|
573
|
+
throw new core_1.InvalidAddressError(params.source, sourceValidation);
|
|
559
574
|
}
|
|
560
575
|
const source = (_b = params.source) !== null && _b !== void 0 ? _b : publicKeyHash;
|
|
561
576
|
const prepared = yield this.prepare.proposals(Object.assign(Object.assign({}, params), { source }));
|
|
@@ -567,8 +582,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
567
582
|
}
|
|
568
583
|
/**
|
|
569
584
|
*
|
|
570
|
-
* @description
|
|
571
|
-
* @remarks updateConsensusKey to a tz4 address is not included in the current beta release for protocol Seoul (still a work in progress)
|
|
585
|
+
* @description Update the consensus key of a delegate starting from the current cycle plus CONSENSUS_RIGHTS_DELAY + 1
|
|
572
586
|
* @returns An operation handle with the result from the rpc node
|
|
573
587
|
*
|
|
574
588
|
* @param UpdateConsensusKeyParams
|
|
@@ -576,6 +590,17 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
576
590
|
updateConsensusKey(params) {
|
|
577
591
|
return __awaiter(this, void 0, void 0, function* () {
|
|
578
592
|
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
593
|
+
const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
|
|
594
|
+
if (pkPrefix === utils_1.PrefixV2.BLS12_381PublicKey) {
|
|
595
|
+
if (!params.proof) {
|
|
596
|
+
throw new core_1.InvalidProofError('Proof is required to set a bls account as consensus key ');
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
if (params.proof) {
|
|
601
|
+
throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as consensus key');
|
|
602
|
+
}
|
|
603
|
+
}
|
|
579
604
|
const estimate = yield this.estimate(params, this.estimator.updateConsensusKey.bind(this.estimator));
|
|
580
605
|
const prepared = yield this.prepare.updateConsensusKey(Object.assign(Object.assign({}, params), estimate));
|
|
581
606
|
const content = prepared.opOb.contents.find((op) => op.kind === rpc_1.OpKind.UPDATE_CONSENSUS_KEY);
|
|
@@ -584,6 +609,31 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
584
609
|
return new update_consensus_key_operation_1.UpdateConsensusKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
585
610
|
});
|
|
586
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
*
|
|
614
|
+
* @description Updates the companion key of the delegate starting from the current cycle plus CONSENSUS_KEY_ACTIVATION_DELAY + 1
|
|
615
|
+
* @returns An operation handle with the result from the rpc node
|
|
616
|
+
*
|
|
617
|
+
* @param UpdateCompanionKeyParams
|
|
618
|
+
*/
|
|
619
|
+
updateCompanionKey(params) {
|
|
620
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
621
|
+
const publicKeyHash = yield this.signer.publicKeyHash();
|
|
622
|
+
const [, pkPrefix] = (0, utils_1.b58DecodeAndCheckPrefix)(params.pk, utils_1.publicKeyPrefixes);
|
|
623
|
+
if (pkPrefix !== utils_1.PrefixV2.BLS12_381PublicKey) {
|
|
624
|
+
throw new core_1.ProhibitedActionError('Proof field is only allowed for a bls account as companion key');
|
|
625
|
+
}
|
|
626
|
+
if (!params.proof) {
|
|
627
|
+
throw new core_1.InvalidProofError('Proof is required to set a bls account as companion key ');
|
|
628
|
+
}
|
|
629
|
+
const estimate = yield this.estimate(params, this.estimator.updateCompanionKey.bind(this.estimator));
|
|
630
|
+
const prepared = yield this.prepare.updateCompanionKey(Object.assign(Object.assign({}, params), estimate));
|
|
631
|
+
const content = prepared.opOb.contents.find((op) => op.kind === rpc_1.OpKind.UPDATE_COMPANION_KEY);
|
|
632
|
+
const opBytes = yield this.forge(prepared);
|
|
633
|
+
const { hash, context, forgedBytes, opResponse } = yield this.signAndInject(opBytes);
|
|
634
|
+
return new update_companion_key_operation_1.UpdateCompanionKeyOperation(hash, content, publicKeyHash, forgedBytes, opResponse, context);
|
|
635
|
+
});
|
|
636
|
+
}
|
|
587
637
|
/**
|
|
588
638
|
* @description Adds messages to the rollup inbox that can be executed/claimed after it gets cemented
|
|
589
639
|
* @param SmartRollupAddMessagesParams
|
|
@@ -678,7 +728,7 @@ class RpcContractProvider extends provider_1.Provider {
|
|
|
678
728
|
return __awaiter(this, arguments, void 0, function* (address, contractAbstractionComposer = (x) => x) {
|
|
679
729
|
const addressValidation = (0, utils_1.validateContractAddress)(address);
|
|
680
730
|
if (addressValidation !== utils_1.ValidationResult.VALID) {
|
|
681
|
-
throw new core_1.InvalidContractAddressError(address,
|
|
731
|
+
throw new core_1.InvalidContractAddressError(address, addressValidation);
|
|
682
732
|
}
|
|
683
733
|
const rpc = this.context.withExtensions().rpc;
|
|
684
734
|
const readProvider = this.context.withExtensions().readProvider;
|