Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Estimation of Multiple Operations #314

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 2020-07-09_Apriorit_Audit.pdf
Binary file not shown.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions src/chain/tezos/TezosNodeWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,25 +653,24 @@ export namespace TezosNodeWriter {
/**
* Dry run the given operation and return consumed resources.
*
* Note: Estimating an operation on an unrevealed account is not supported and will fail.
*
* TODO: Add support for estimating multiple operations so that reveals can be processed.
* Note: Estimating an operation on an unrevealed account is not supported and will fail. Remember to prepend
* the Reveal operation if required.
*
* @param {string} server Tezos node to connect to
* @param {string} chainid The chain ID to apply the operation on.
* @param {TezosP2PMessageTypes.Operation} operation The operation to estimate.
* @param {TezosP2PMessageTypes.Operation} operations A set of operations to update.
* @returns A two-element object gas and storage costs. Throws an error if one was encountered.
*/
export async function estimateOperation(
server: string,
chainid: string,
operation: TezosP2PMessageTypes.Operation
...operations: TezosP2PMessageTypes.Operation[]
): Promise<{ gas: number, storageCost: number }> {
const fake_signature = 'edsigu6xFLH2NpJ1VcYshpjW99Yc1TAL1m2XBqJyXrxcZQgBMo8sszw2zm626yjpA3pWMhjpsahLrWdmvX9cqhd4ZEUchuBuFYy';
const fake_chainid = 'NetXdQprcVkpaWU';
const fake_branch = 'BL94i2ShahPx3BoNs6tJdXDdGeoJ9ukwujUA2P8WJwULYNdimmq';

const response = await performPostRequest(server, `chains/${chainid}/blocks/head/helpers/scripts/run_operation`, { chain_id: fake_chainid, operation: { branch: fake_branch, contents: [operation], signature: fake_signature } });
const response = await performPostRequest(server, `chains/${chainid}/blocks/head/helpers/scripts/run_operation`, { chain_id: fake_chainid, operation: { branch: fake_branch, contents: operations, signature: fake_signature } });
const responseText = await response.text();

parseRPCError(responseText);
Expand Down