conseiljs
Advanced tools
Comparing version 5.0.7-beta.3 to 5.0.7-beta.4
@@ -35,2 +35,3 @@ "use strict"; | ||
const log = LoggerSelector_1.default.log; | ||
const counterMatcher = new RegExp(/.*Counter [0-9]{1,} already used for contract.*/, 'gm'); | ||
let operationQueues = {}; | ||
@@ -212,11 +213,3 @@ var TezosNodeWriter; | ||
}; | ||
const operations = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [transaction]); | ||
if (optimizeFee) { | ||
const estimate = yield estimateOperationGroup(server, 'main', operations); | ||
operations[0].fee = estimate.estimatedFee.toString(); | ||
for (let i = 0; i < operations.length; i++) { | ||
operations[i].gas_limit = estimate.operationResources[i].gas.toString(); | ||
operations[i].storage_limit = estimate.operationResources[i].storageCost.toString(); | ||
} | ||
} | ||
const operations = yield prepareOperation(server, keyStore, counter, transaction, optimizeFee); | ||
return sendOperation(server, operations, signer, offset); | ||
@@ -238,11 +231,3 @@ }); | ||
}; | ||
const operations = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [delegation]); | ||
if (optimizeFee) { | ||
const estimate = yield estimateOperationGroup(server, 'main', operations); | ||
operations[0].fee = estimate.estimatedFee.toString(); | ||
for (let i = 0; i < operations.length; i++) { | ||
operations[i].gas_limit = estimate.operationResources[i].gas.toString(); | ||
operations[i].storage_limit = estimate.operationResources[i].storageCost.toString(); | ||
} | ||
} | ||
const operations = yield prepareOperation(server, keyStore, counter, delegation, optimizeFee); | ||
return sendOperation(server, operations, signer, offset); | ||
@@ -261,12 +246,4 @@ }); | ||
const counter = (yield TezosNodeReader_1.TezosNodeReader.getCounterForAccount(server, keyStore.publicKeyHash)) + 1; | ||
const operation = constructContractOriginationOperation(keyStore, amount, delegate, fee, storageLimit, gasLimit, code, storage, codeFormat, counter); | ||
const operations = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [operation]); | ||
if (optimizeFee) { | ||
const estimate = yield estimateOperationGroup(server, 'main', operations); | ||
operations[0].fee = estimate.estimatedFee.toString(); | ||
for (let i = 0; i < operations.length; i++) { | ||
operations[i].gas_limit = estimate.operationResources[i].gas.toString(); | ||
operations[i].storage_limit = estimate.operationResources[i].storageCost.toString(); | ||
} | ||
} | ||
const origination = constructContractOriginationOperation(keyStore, amount, delegate, fee, storageLimit, gasLimit, code, storage, codeFormat, counter); | ||
const operations = yield prepareOperation(server, keyStore, counter, origination, optimizeFee); | ||
return sendOperation(server, operations, signer, offset); | ||
@@ -306,9 +283,3 @@ }); | ||
const transaction = constructContractInvocationOperation(keyStore.publicKeyHash, counter, contract, amount, fee, storageLimit, gasLimit, entrypoint, parameters, parameterFormat); | ||
const operations = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [transaction]); | ||
const estimate = yield estimateOperationGroup(server, 'main', operations); | ||
operations[0].fee = estimate.estimatedFee.toString(); | ||
for (let i = 0; i < operations.length; i++) { | ||
operations[i].gas_limit = estimate.operationResources[i].gas.toString(); | ||
operations[i].storage_limit = estimate.operationResources[i].storageCost.toString(); | ||
} | ||
const operations = yield prepareOperation(server, keyStore, counter, transaction, optimizeFee); | ||
return sendOperation(server, operations, signer, offset); | ||
@@ -475,2 +446,16 @@ }); | ||
TezosNodeWriter.dryRunOperation = dryRunOperation; | ||
function prepareOperation(server, keyStore, counter, operation, optimizeFee = false) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const operationGroup = yield appendRevealOperation(server, keyStore.publicKey, keyStore.publicKeyHash, counter - 1, [operation]); | ||
if (optimizeFee) { | ||
const estimate = yield estimateOperationGroup(server, 'main', operationGroup); | ||
operationGroup[0].fee = estimate.estimatedFee.toString(); | ||
for (let i = 0; i < operationGroup.length; i++) { | ||
operationGroup[i].gas_limit = estimate.operationResources[i].gas.toString(); | ||
operationGroup[i].storage_limit = estimate.operationResources[i].storageCost.toString(); | ||
} | ||
} | ||
return operationGroup; | ||
}); | ||
} | ||
function parseRPCError(response) { | ||
@@ -483,2 +468,8 @@ let errors = ''; | ||
errors = arr.map(e => { | ||
if (e.msg) { | ||
if (counterMatcher.test(e.msg)) { | ||
return `(${e.kind}: ${e.id}, counter already used)`; | ||
} | ||
return `(${e.kind}: ${e.id}, ${e.msg})`; | ||
} | ||
return `(${e.kind}: ${e.id})`; | ||
@@ -485,0 +476,0 @@ }).join(', '); |
{ | ||
"name": "conseiljs", | ||
"version": "5.0.7-beta.3", | ||
"version": "5.0.7-beta.4", | ||
"description": "Client-side library for Tezos dApp development.", | ||
@@ -5,0 +5,0 @@ "browser": "dist/index-web.js", |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
782604
7555