Repository: ecadlabs/taquito
Pull request #1435 (2022-03-03 19:15:00)

refactor(estimate): moved all estimate files in a separate folder
Thank you for your contribution to Taquito.

Before submitting this PR, please make sure:

- [ ] Your code builds cleanly without any errors or warnings
- [ ] You have added unit tests
- [ ] You have added integration tests (if relevant/appropriate)
- [ ] All public methods or types have TypeDoc coverage with a complete description, and ideally an @example
- [ ] You have added or updated corresponding documentation
- [ ] If relevant, you have written a first draft summary describing the change for inclusion in Release Notes. 

## Release Note Draft Snippet

__If relevant, please write a summary of your change that will be suitable for
inclusion in the Release Notes for the next Taquito release.__



Patch:
diff --git a/packages/taquito/src/batch/rpc-batch-provider.ts b/packages/taquito/src/batch/rpc-batch-provider.ts
index 6f04bcbf7..041a843af 100644
--- a/packages/taquito/src/batch/rpc-batch-provider.ts
+++ b/packages/taquito/src/batch/rpc-batch-provider.ts
@@ -1,7 +1,7 @@
 import { Context } from '../context';
 import { ContractStorageType, DefaultContractType } from '../contract/contract';
 import { ContractMethod } from '../contract/contract-methods/contract-method-flat-param';
-import { EstimationProvider, ContractProvider } from '../contract/interface';
+import { ContractProvider } from '../contract/interface';
 import {
   createOriginationOperation,
   createRegisterGlobalConstantOperation,
@@ -25,13 +25,14 @@ import {
 } from '../operations/types';
 import { OpKind } from '@taquito/rpc';
 import { ContractMethodObject } from '../contract/contract-methods/contract-method-object-param';
-import { 
-  validateAddress, 
-  validateKeyHash, 
-  InvalidAddressError, 
-  InvalidKeyHashError, 
-  ValidationResult 
-} from '@taquito/utils'
+import {
+  validateAddress,
+  validateKeyHash,
+  InvalidAddressError,
+  InvalidKeyHashError,
+  ValidationResult,
+} from '@taquito/utils';
+import { EstimationProvider } from '../estimate/estimate-provider-interface';
 
 export const BATCH_KINDS = [
   OpKind.ACTIVATION,
@@ -60,7 +61,7 @@ export class OperationBatch extends OperationEmitter {
    */
   withTransfer(params: TransferParams) {
     if (validateAddress(params.to) !== ValidationResult.VALID) {
-      throw new InvalidAddressError(`Invalid 'to' address: ${params.to}`)
+      throw new InvalidAddressError(`Invalid 'to' address: ${params.to}`);
     }
     this.operations.push({ kind: OpKind.TRANSACTION, ...params });
     return this;
@@ -72,7 +73,9 @@ export class OperationBatch extends OperationEmitter {
    *
    * @param params Transfer operation parameter
    */
-  withContractCall(params: ContractMethod<ContractProvider> | ContractMethodObject<ContractProvider>) {
+  withContractCall(
+    params: ContractMethod<ContractProvider> | ContractMethodObject<ContractProvider>
+  ) {
     return this.withTransfer(params.toTransferParams());
   }
 
@@ -113,7 +116,9 @@ export class OperationBatch extends OperationEmitter {
    *
    * @param params Origination operation parameter
    */
-  withOrigination<TContract extends DefaultContractType = DefaultContractType>(params: OriginateParams<ContractStorageType<TContract>>) {
+  withOrigination<TContract extends DefaultContractType = DefaultContractType>(
+    params: OriginateParams<ContractStorageType<TContract>>
+  ) {
     this.operations.push({ kind: OpKind.ORIGINATION, ...params });
     return this;
   }
@@ -124,7 +129,7 @@ export class OperationBatch extends OperationEmitter {
    *
    * @param params RegisterGlobalConstant operation parameter
    */
-   withRegisterGlobalConstant(params: RegisterGlobalConstantParams) {
+  withRegisterGlobalConstant(params: RegisterGlobalConstantParams) {
     this.operations.push({ kind: OpKind.REGISTER_GLOBAL_CONSTANT, ...params });
     return this;
   }
@@ -138,8 +143,9 @@ export class OperationBatch extends OperationEmitter {
       case OpKind.ORIGINATION:
         return createOriginationOperation(
           await this.context.parser.prepareCodeOrigination({
-          ...param,
-        }));
+            ...param,
+          })
+        );
       case OpKind.DELEGATION:
         return createSetDelegateOperation({
           ...param,
@@ -214,9 +220,9 @@ export class OperationBatch extends OperationEmitter {
       i++;
     }
     if (revealNeeded) {
-      const reveal: withKind<RevealParams, OpKind.REVEAL> = { kind: OpKind.REVEAL }
+      const reveal: withKind<RevealParams, OpKind.REVEAL> = { kind: OpKind.REVEAL };
       const estimatedReveal = await this.estimate(reveal, async () => estimates[0]);
-      ops.unshift(await createRevealOperation({ ...estimatedReveal }, publicKeyHash, publicKey))
+      ops.unshift(await createRevealOperation({ ...estimatedReveal }, publicKeyHash, publicKey));
     }
 
     const source = (params && params.source) || publicKeyHash;
@@ -231,7 +237,7 @@ export class OperationBatch extends OperationEmitter {
 }
 
 export class RPCBatchProvider {
-  constructor(private context: Context, private estimator: EstimationProvider) { }
+  constructor(private context: Context, private estimator: EstimationProvider) {}
 
   /***
    *
diff --git a/packages/taquito/src/context.ts b/packages/taquito/src/context.ts
index 164ca4cfd..5ebb14514 100644
--- a/packages/taquito/src/context.ts
+++ b/packages/taquito/src/context.ts
@@ -7,7 +7,7 @@ import { Signer } from './signer/interface';
 import { NoopSigner } from './signer/noop';
 import { OperationFactory } from './wallet/operation-factory';
 import { RpcTzProvider } from './tz/rpc-tz-provider';
-import { RPCEstimateProvider } from './contract/rpc-estimate-provider';
+import { RPCEstimateProvider } from './estimate/rpc-estimate-provider';
 import { RpcContractProvider } from './contract/rpc-contract-provider';
 import { RPCBatchProvider } from './batch/rpc-batch-provider';
 
@@ -229,7 +229,7 @@ export class Context {
   }
 
   /**
-   * @description Allows extensions set on the TezosToolkit to inject logic into the context 
+   * @description Allows extensions set on the TezosToolkit to inject logic into the context
    */
   registerProviderDecorator(fx: (context: Context) => Context) {
     this.providerDecorator.push(fx);
diff --git a/packages/taquito/src/contract/interface.ts b/packages/taquito/src/contract/interface.ts
index 269f8350e..2b43c92fe 100644
--- a/packages/taquito/src/contract/interface.ts
+++ b/packages/taquito/src/contract/interface.ts
@@ -17,74 +17,9 @@ import {
   RegisterGlobalConstantParams,
 } from '../operations/types';
 import { ContractAbstraction, ContractStorageType, DefaultContractType } from './contract';
-import { Estimate } from './estimate';
 
 export type ContractSchema = Schema | unknown;
 
-export interface EstimationProvider {
-  /**
-   *
-   * @description Estimate gasLimit, storageLimit and fees for an origination operation
-   *
-   * @returns An estimation of gasLimit, storageLimit and fees for the operation
-   *
-   * @param Estimate
-   */
-  originate(params: OriginateParams): Promise<Estimate>;
-
-  /**
-   *
-   * @description Estimate gasLimit, storageLimit and fees for an transfer operation
-   *
-   * @returns An estimation of gasLimit, storageLimit and fees for the operation
-   *
-   * @param Estimate
-   */
-  transfer({ fee, storageLimit, gasLimit, ...rest }: TransferParams): Promise<Estimate>;
-
-  /**
-   *
-   * @description Estimate gasLimit, storageLimit and fees for a delegate operation
-   *
-   * @returns An estimation of gasLimit, storageLimit and fees for the operation
-   *
-   * @param Estimate
-   */
-  setDelegate(params: DelegateParams): Promise<Estimate>;
-
-  /**
-   *
-   * @description Estimate gasLimit, storageLimit and fees for a delegate operation
-   *
-   * @returns An estimation of gasLimit, storageLimit and fees for the operation
-   *
-   * @param Estimate
-   */
-  registerDelegate(params?: RegisterDelegateParams): Promise<Estimate>;
-
-  /**
-   *
-   * @description Estimate gasLimit, storageLimit and fees for a reveal operation
-   *
-   * @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
-   *
-   * @param Estimate
-   */
-  reveal(params?: RevealParams): Promise<Estimate | undefined> ;
-
-  batch(params: ParamsWithKind[]): Promise<Estimate[]>;
-
-  /**
-   *
-   * @description Estimate gasLimit, storageLimit and fees for registering an expression (registerGlobalConstant operation) 
-   *
-   * @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
-   *
-   * @param params registerGlobalConstant operation parameter
-   */
-  registerGlobalConstant(params: RegisterGlobalConstantParams): Promise<Estimate>;
-}
-
 export interface StorageProvider {
   /**
    *
@@ -122,7 +57,12 @@ export interface StorageProvider {
    *
    * @see https://tezos.gitlab.io/api/rpc.html#get-block-id-context-big-maps-big-map-id-script-expr
    */
-  getBigMapKeyByID<T>(id: string, keyToEncode: BigMapKeyType, schema: Schema, block?: number): Promise<T>;
+  getBigMapKeyByID<T>(
+    id: string,
+    keyToEncode: BigMapKeyType,
+    schema: Schema,
+    block?: number
+  ): Promise<T>;
 
   /**
    *
@@ -136,7 +76,13 @@ export interface StorageProvider {
    * @returns An object containing the keys queried in the big map and their value in a well-formatted JSON object format
    *
    */
-   getBigMapKeysByID<T>(id: string, keysToEncode: Array<BigMapKeyType>, schema: Schema, block?: number, batchSize?: number): Promise<MichelsonMap<MichelsonMapKey, T | undefined>>;
+  getBigMapKeysByID<T>(
+    id: string,
+    keysToEncode: Array<BigMapKeyType>,
+    schema: Schema,
+    block?: number,
+    batchSize?: number
+  ): Promise<MichelsonMap<MichelsonMapKey, T | undefined>>;
 
   /**
    *
@@ -146,7 +92,7 @@ export interface StorageProvider {
    * @param block optional block level to fetch the value from
    *
    */
-   getSaplingDiffByID(id: string, block?: number): Promise<SaplingDiffResponse>;
+  getSaplingDiffByID(id: string, block?: number): Promise<SaplingDiffResponse>;
 }
 
 export interface ContractProvider extends StorageProvider {
@@ -158,7 +104,9 @@ export interface ContractProvider extends StorageProvider {
    *
    * @param OriginationOperation Originate operation parameter
    */
-  originate<TContract extends DefaultContractType = DefaultContractType>(contract: OriginateParams<ContractStorageType<TContract>>): Promise<OriginationOperation<TContract>>;
+  originate<TContract extends DefaultContractType = DefaultContractType>(
+    contract: OriginateParams<ContractStorageType<TContract>>
+  ): Promise<OriginationOperation<TContract>>;
 
   /**
    *
@@ -200,7 +148,13 @@ export interface ContractProvider extends StorageProvider {
    */
   reveal(params: RevealParams): Promise<RevealOperation>;
 
-  at<T extends ContractAbstraction<ContractProvider>>(address: string, contractAbstractionComposer?: (abs: ContractAbstraction<ContractProvider>, context: Context) => T): Promise<T>;
+  at<T extends ContractAbstraction<ContractProvider>>(
+    address: string,
+    contractAbstractionComposer?: (
+      abs: ContractAbstraction<ContractProvider>,
+      context: Context
+    ) => T
+  ): Promise<T>;
 
   /**
    *
@@ -208,7 +162,7 @@ export interface ContractProvider extends StorageProvider {
    *
    * @param params List of operation to batch together
    */
-  batch(params?: ParamsWithKind[]): OperationBatch ;
+  batch(params?: ParamsWithKind[]): OperationBatch;
 
   /**
    *
@@ -218,5 +172,7 @@ export interface ContractProvider extends StorageProvider {
    *
    * @param params registerGlobalConstant operation parameter
    */
-  registerGlobalConstant(params: RegisterGlobalConstantParams): Promise<RegisterGlobalConstantOperation>;
+  registerGlobalConstant(
+    params: RegisterGlobalConstantParams
+  ): Promise<RegisterGlobalConstantOperation>;
 }
diff --git a/packages/taquito/src/contract/rpc-contract-provider.ts b/packages/taquito/src/contract/rpc-contract-provider.ts
index cdd5cc6b0..52805642e 100644
--- a/packages/taquito/src/contract/rpc-contract-provider.ts
+++ b/packages/taquito/src/contract/rpc-contract-provider.ts
@@ -1,6 +1,6 @@
 import { HttpResponseError, STATUS_CODE } from '@taquito/http-utils';
 import { BigMapKeyType, MichelsonMap, MichelsonMapKey, Schema } from '@taquito/michelson-encoder';
-import { MichelsonV1Expression, OpKind, ScriptResponse } from '@taquito/rpc';
+import { OpKind, ScriptResponse } from '@taquito/rpc';
 import { encodeExpr } from '@taquito/utils';
 import { OperationBatch } from '../batch/rpc-batch-provider';
 import { Context } from '../context';
@@ -24,7 +24,7 @@ import {
 } from '../operations/types';
 import { DefaultContractType, ContractStorageType, ContractAbstraction } from './contract';
 import { InvalidDelegationSource } from './errors';
-import { ContractProvider, ContractSchema, EstimationProvider, StorageProvider } from './interface';
+import { ContractProvider, ContractSchema, StorageProvider } from './interface';
 import {
   createOriginationOperation,
   createRegisterDelegateOperation,
@@ -41,6 +41,7 @@ import {
   InvalidAddressError,
   ValidationResult,
 } from '@taquito/utils';
+import { EstimationProvider } from '../estimate/estimate-provider-interface';
 export class RpcContractProvider
   extends OperationEmitter
   implements ContractProvider, StorageProvider
diff --git a/packages/taquito/src/estimate/estimate-provider-interface.ts b/packages/taquito/src/estimate/estimate-provider-interface.ts
new file mode 100644
index 000000000..f0c2491f2
--- /dev/null
+++ b/packages/taquito/src/estimate/estimate-provider-interface.ts
@@ -0,0 +1,73 @@
+import {
+  OriginateParams,
+  TransferParams,
+  DelegateParams,
+  RegisterDelegateParams,
+  ParamsWithKind,
+} from '../operations';
+import { RevealParams, RegisterGlobalConstantParams } from '../operations/types';
+import { Estimate } from './estimate';
+
+export interface EstimationProvider {
+  /**
+   *
+   * @description Estimate gasLimit, storageLimit and fees for an origination operation
+   *
+   * @returns An estimation of gasLimit, storageLimit and fees for the operation
+   *
+   * @param Estimate
+   */
+  originate(params: OriginateParams): Promise<Estimate>;
+
+  /**
+   *
+   * @description Estimate gasLimit, storageLimit and fees for an transfer operation
+   *
+   * @returns An estimation of gasLimit, storageLimit and fees for the operation
+   *
+   * @param Estimate
+   */
+  transfer({ fee, storageLimit, gasLimit, ...rest }: TransferParams): Promise<Estimate>;
+
+  /**
+   *
+   * @description Estimate gasLimit, storageLimit and fees for a delegate operation
+   *
+   * @returns An estimation of gasLimit, storageLimit and fees for the operation
+   *
+   * @param Estimate
+   */
+  setDelegate(params: DelegateParams): Promise<Estimate>;
+
+  /**
+   *
+   * @description Estimate gasLimit, storageLimit and fees for a delegate operation
+   *
+   * @returns An estimation of gasLimit, storageLimit and fees for the operation
+   *
+   * @param Estimate
+   */
+  registerDelegate(params?: RegisterDelegateParams): Promise<Estimate>;
+
+  /**
+   *
+   * @description Estimate gasLimit, storageLimit and fees for a reveal operation
+   *
+   * @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
+   *
+   * @param Estimate
+   */
+  reveal(params?: RevealParams): Promise<Estimate | undefined>;
+
+  batch(params: ParamsWithKind[]): Promise<Estimate[]>;
+
+  /**
+   *
+   * @description Estimate gasLimit, storageLimit and fees for registering an expression (registerGlobalConstant operation)
+   *
+   * @returns An estimation of gasLimit, storageLimit and fees for the operation or undefined if the account is already revealed
+   *
+   * @param params registerGlobalConstant operation parameter
+   */
+  registerGlobalConstant(params: RegisterGlobalConstantParams): Promise<Estimate>;
+}
diff --git a/packages/taquito/src/contract/estimate.ts b/packages/taquito/src/estimate/estimate.ts
similarity index 81%
rename from packages/taquito/src/contract/estimate.ts
rename to packages/taquito/src/estimate/estimate.ts
index 0a23874e7..eb9f162eb 100644
--- a/packages/taquito/src/contract/estimate.ts
+++ b/packages/taquito/src/estimate/estimate.ts
@@ -5,11 +5,11 @@ const MINIMAL_FEE_PER_GAS_MUTEZ = 0.1;
 const GAS_BUFFER = 100;
 
 export interface EstimateProperties {
-  milligasLimit: number,
-  storageLimit: number,
-  opSize: number,
-  minimalFeePerStorageByteMutez: number,
-  baseFeeMutez?: number
+  milligasLimit: number;
+  storageLimit: number;
+  opSize: number;
+  minimalFeePerStorageByteMutez: number;
+  baseFeeMutez?: number;
 }
 
 /**
@@ -79,13 +79,14 @@ export class Estimate {
    * @description The limit on the amount of [gas](https://tezos.gitlab.io/user/glossary.html#gas) a given operation can consume.
    */
   get gasLimit() {
-    return this.roundUp(Number(this._milligasLimit)/1000 + GAS_BUFFER);
+    return this.roundUp(Number(this._milligasLimit) / 1000 + GAS_BUFFER);
   }
 
   private get operationFeeMutez() {
     return (
-      (Number(this._milligasLimit)/1000 + GAS_BUFFER) * MINIMAL_FEE_PER_GAS_MUTEZ + Number(this.opSize) * MINIMAL_FEE_PER_BYTE_MUTEZ
-      );
+      (Number(this._milligasLimit) / 1000 + GAS_BUFFER) * MINIMAL_FEE_PER_GAS_MUTEZ +
+      Number(this.opSize) * MINIMAL_FEE_PER_BYTE_MUTEZ
+    );
   }
 
   private roundUp(nanotez: number) {
@@ -123,8 +124,8 @@ export class Estimate {
   }
 
   /**
-   * @description Since Delphinet, consumed gas is provided in milligas for more precision. 
-   * This function returns an estimation of the gas that operation will consume in milligas. 
+   * @description Since Delphinet, consumed gas is provided in milligas for more precision.
+   * This function returns an estimation of the gas that operation will consume in milligas.
    */
   get consumedMilligas() {
     return Number(this._milligasLimit);
@@ -137,19 +138,37 @@ export class Estimate {
     let minimalFeePerStorageByteMutez = 0;
     let baseFeeMutez: number | undefined;
 
-    estimateProperties.forEach(estimate => {
+    estimateProperties.forEach((estimate) => {
       milligasLimit += estimate.milligasLimit;
       storageLimit += estimate.storageLimit;
       opSize += estimate.opSize;
-      minimalFeePerStorageByteMutez = Math.max(estimate.minimalFeePerStorageByteMutez, minimalFeePerStorageByteMutez);
+      minimalFeePerStorageByteMutez = Math.max(
+        estimate.minimalFeePerStorageByteMutez,
+        minimalFeePerStorageByteMutez
+      );
       if (estimate.baseFeeMutez) {
         baseFeeMutez = baseFeeMutez ? baseFeeMutez + estimate.baseFeeMutez : estimate.baseFeeMutez;
       }
-    })
-    return new Estimate(milligasLimit, storageLimit, opSize, minimalFeePerStorageByteMutez, baseFeeMutez);
+    });
+    return new Estimate(
+      milligasLimit,
+      storageLimit,
+      opSize,
+      minimalFeePerStorageByteMutez,
+      baseFeeMutez
+    );
   }
 
   static createArrayEstimateInstancesFromProperties(estimateProperties: EstimateProperties[]) {
-    return estimateProperties.map(x => new Estimate(x.milligasLimit, x.storageLimit, x.opSize, x.minimalFeePerStorageByteMutez, x.baseFeeMutez))
+    return estimateProperties.map(
+      (x) =>
+        new Estimate(
+          x.milligasLimit,
+          x.storageLimit,
+          x.opSize,
+          x.minimalFeePerStorageByteMutez,
+          x.baseFeeMutez
+        )
+    );
   }
 }
diff --git a/packages/taquito/src/estimate/index.ts b/packages/taquito/src/estimate/index.ts
new file mode 100644
index 000000000..03cebd867
--- /dev/null
+++ b/packages/taquito/src/estimate/index.ts
@@ -0,0 +1,4 @@
+export * from './estimate';
+export * from './estimate-provider-interface';
+export * from './naive-estimate-provider';
+export * from './rpc-estimate-provider';
diff --git a/packages/taquito/src/contract/naive-estimate-provider.ts b/packages/taquito/src/estimate/naive-estimate-provider.ts
similarity index 88%
rename from packages/taquito/src/contract/naive-estimate-provider.ts
rename to packages/taquito/src/estimate/naive-estimate-provider.ts
index 3e4cc507c..9db721089 100644
--- a/packages/taquito/src/contract/naive-estimate-provider.ts
+++ b/packages/taquito/src/estimate/naive-estimate-provider.ts
@@ -1,19 +1,22 @@
 import { DEFAULT_FEE, DEFAULT_GAS_LIMIT, DEFAULT_STORAGE_LIMIT, Protocols } from '../constants';
-import { OriginateParams, TransferParams, ParamsWithKind, RegisterGlobalConstantParams } from '../operations/types';
+import {
+  OriginateParams,
+  TransferParams,
+  ParamsWithKind,
+  RegisterGlobalConstantParams,
+} from '../operations/types';
 import { Estimate } from './estimate';
-import { EstimationProvider } from './interface';
+import { EstimationProvider } from '../estimate/estimate-provider-interface';
 
 /**
  * @description Naïve implementation of an estimate provider. Will work for basic transaction but your operation risk to fail if they are more complex (smart contract interaction)
- * 
+ *
  * @deprecated Deprecated in favor of RPCEstimateProvider
  */
 export class NaiveEstimateProvider implements EstimationProvider {
   private _costPerByte: number;
-  constructor(
-    private readonly protocol: Protocols,
-  ) {
-      this._costPerByte = 250;
+  constructor(private readonly protocol: Protocols) {
+    this._costPerByte = 250;
   }
   registerGlobalConstant(params: RegisterGlobalConstantParams): Promise<Estimate> {
     throw new Error(`Unsupported operation kind: ${(params as any).kind}`);
@@ -89,7 +92,13 @@ export class NaiveEstimateProvider implements EstimationProvider {
    * @param Estimate
    */
   async reveal() {
-    return new Estimate(DEFAULT_GAS_LIMIT.REVEAL * 1000, DEFAULT_STORAGE_LIMIT.REVEAL, 64, this._costPerByte, DEFAULT_FEE.REVEAL);
+    return new Estimate(
+      DEFAULT_GAS_LIMIT.REVEAL * 1000,
+      DEFAULT_STORAGE_LIMIT.REVEAL,
+      64,
+      this._costPerByte,
+      DEFAULT_FEE.REVEAL
+    );
   }
 
   async batch(params: ParamsWithKind[]) {
diff --git a/packages/taquito/src/contract/rpc-estimate-provider.ts b/packages/taquito/src/estimate/rpc-estimate-provider.ts
similarity index 99%
rename from packages/taquito/src/contract/rpc-estimate-provider.ts
rename to packages/taquito/src/estimate/rpc-estimate-provider.ts
index 3a3b230c6..5a11c90d9 100644
--- a/packages/taquito/src/contract/rpc-estimate-provider.ts
+++ b/packages/taquito/src/estimate/rpc-estimate-provider.ts
@@ -20,7 +20,7 @@ import {
   RegisterGlobalConstantParams,
 } from '../operations/types';
 import { Estimate, EstimateProperties } from './estimate';
-import { EstimationProvider } from './interface';
+import { EstimationProvider } from '../estimate/estimate-provider-interface';
 import {
   createOriginationOperation,
   createRegisterDelegateOperation,
@@ -28,7 +28,7 @@ import {
   createSetDelegateOperation,
   createTransferOperation,
   createRegisterGlobalConstantOperation,
-} from './prepare';
+} from '../contract/prepare';
 import { validateAddress, InvalidAddressError, ValidationResult } from '@taquito/utils';
 
 interface Limits {
diff --git a/packages/taquito/src/operations/operation-emitter.ts b/packages/taquito/src/operations/operation-emitter.ts
index 1cc73e73e..140c1015b 100644
--- a/packages/taquito/src/operations/operation-emitter.ts
+++ b/packages/taquito/src/operations/operation-emitter.ts
@@ -7,7 +7,7 @@ import {
 } from '@taquito/rpc';
 import { Protocols } from '../constants';
 import { Context } from '../context';
-import { Estimate } from '../contract/estimate';
+import { Estimate } from '../estimate/estimate';
 import { flattenErrors, TezosOperationError, TezosPreapplyFailureError } from './operation-errors';
 import {
   ForgedBytes,
diff --git a/packages/taquito/src/taquito.ts b/packages/taquito/src/taquito.ts
index 99fb48713..8a2bee707 100644
--- a/packages/taquito/src/taquito.ts
+++ b/packages/taquito/src/taquito.ts
@@ -8,7 +8,7 @@ import { Forger } from '@taquito/local-forging';
 import { RPCBatchProvider } from './batch/rpc-batch-provider';
 import { Protocols } from './constants';
 import { ConfigConfirmation, Context, TaquitoProvider } from './context';
-import { ContractProvider, EstimationProvider } from './contract/interface';
+import { ContractProvider } from './contract/interface';
 import { Extension } from './extension/extension';
 import { format } from './format';
 import { GlobalConstantsProvider } from './global-constants/interface-global-constants-provider';
@@ -26,6 +26,7 @@ import { VERSION } from './version';
 import { LegacyWalletProvider, Wallet, WalletProvider } from './wallet';
 import { OperationFactory } from './wallet/operation-factory';
 import { TaquitoLocalForger } from './forger/taquito-local-forger';
+import { EstimationProvider } from './estimate/estimate-provider-interface';
 
 export { MichelsonMap, UnitValue } from '@taquito/michelson-encoder';
 export { Forger, ForgeParams, ForgeResponse } from '@taquito/local-forging';
@@ -57,6 +58,7 @@ export * from './global-constants/error';
 export * from './global-constants/interface-global-constants-provider';
 export * from './read-provider/interface';
 export * from './read-provider/rpc-read-adapter';
+export * from './estimate';
 
 export interface SetProviderOptions {
   forger?: Forger;


Test patch:
diff --git a/packages/taquito/test/batch/rpc-batch-provider.spec.ts b/packages/taquito/test/batch/rpc-batch-provider.spec.ts
index ea9563ec3..71f03fcb7 100644
--- a/packages/taquito/test/batch/rpc-batch-provider.spec.ts
+++ b/packages/taquito/test/batch/rpc-batch-provider.spec.ts
@@ -1,6 +1,6 @@
 import { OperationBatch } from '../../src/batch/rpc-batch-provider';
 import { Context } from '../../src/context';
-import { Estimate } from '../../src/contract/estimate';
+import { Estimate } from '../../src/estimate/estimate';
 import { OpKind, ParamsWithKind } from '../../src/operations/types';
 
 /**
diff --git a/packages/taquito/test/contract/rpc-contract-provider.spec.ts b/packages/taquito/test/contract/rpc-contract-provider.spec.ts
index 123077cb8..a4b3d1781 100644
--- a/packages/taquito/test/contract/rpc-contract-provider.spec.ts
+++ b/packages/taquito/test/contract/rpc-contract-provider.spec.ts
@@ -16,7 +16,7 @@ import {
 import BigNumber from 'bignumber.js';
 import { Context } from '../../src/context';
 import { ContractMethod } from '../../src/contract/contract-methods/contract-method-flat-param';
-import { Estimate } from '../../src/contract/estimate';
+import { Estimate } from '../../src/estimate/estimate';
 import {
   Protocols,
   DEFAULT_STORAGE_LIMIT,
diff --git a/packages/taquito/test/contract/estimate.spec.ts b/packages/taquito/test/estimate/estimate.spec.ts
similarity index 97%
rename from packages/taquito/test/contract/estimate.spec.ts
rename to packages/taquito/test/estimate/estimate.spec.ts
index 96cc323cf..66293e3de 100644
--- a/packages/taquito/test/contract/estimate.spec.ts
+++ b/packages/taquito/test/estimate/estimate.spec.ts
@@ -1,4 +1,4 @@
-import { Estimate } from '../../src/contract/estimate';
+import { Estimate } from '../../src/estimate/estimate';
 
 describe('Estimate', () => {
   it('Calculate fees in mutez properly for Carthagenet', () => {
diff --git a/packages/taquito/test/contract/rpc-estimate-provider.spec.ts b/packages/taquito/test/estimate/rpc-estimate-provider.spec.ts
similarity index 99%
rename from packages/taquito/test/contract/rpc-estimate-provider.spec.ts
rename to packages/taquito/test/estimate/rpc-estimate-provider.spec.ts
index 19215ca53..649ccba15 100644
--- a/packages/taquito/test/contract/rpc-estimate-provider.spec.ts
+++ b/packages/taquito/test/estimate/rpc-estimate-provider.spec.ts
@@ -1,6 +1,6 @@
 import { Context } from '../../src/context';
-import { RPCEstimateProvider } from '../../src/contract/rpc-estimate-provider';
-import { miStr, ligoSample } from './data';
+import { RPCEstimateProvider } from '../../src/estimate/rpc-estimate-provider';
+import { miStr, ligoSample } from '../contract/data';
 import BigNumber from 'bignumber.js';
 import {
   preapplyResultFrom,
@@ -15,7 +15,7 @@ import {
   registerGlobalConstantNoReveal,
   registerGlobalConstantWithReveal,
   registerGlobalConstantWithError,
-} from './helper';
+} from '../contract/helper';
 import { OpKind } from '@taquito/rpc';
 
 /**
diff --git a/packages/taquito/test/taquito.spec.ts b/packages/taquito/test/taquito.spec.ts
index db7fe353f..49eb7cf3b 100644
--- a/packages/taquito/test/taquito.spec.ts
+++ b/packages/taquito/test/taquito.spec.ts
@@ -4,7 +4,7 @@ import { RpcContractProvider } from '../src/contract/rpc-contract-provider';
 import { PollingSubscribeProvider } from '../src/subscribe/polling-subcribe-provider';
 import { NoopSigner } from '../src/signer/noop';
 import { RpcClient } from '@taquito/rpc';
-import { RPCEstimateProvider } from '../src/contract/rpc-estimate-provider';
+import { RPCEstimateProvider } from '../src/estimate/rpc-estimate-provider';
 import { OperationFactory } from '../src/wallet/operation-factory';
 import { NoopGlobalConstantsProvider } from '../src/global-constants/noop-global-constants-provider';
 import { TaquitoLocalForger } from '../src/forger/taquito-local-forger';