Skip to content

Commit

Permalink
Hotfix: target pending block in estimateFee
Browse files Browse the repository at this point in the history
  • Loading branch information
FabijanC committed Mar 28, 2022
1 parent 4ce3a4b commit af3834f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,17 @@ export function parseFeeEstimation(raw: string): FeeEstimation {
throw new HardhatPluginError(PLUGIN_NAME, "Cannot parse fee estimation response.");
}

/**
* Modifies the passed object by setting its blockNumber to pending.
* @param options the options object with a blockNumber key
*/
function defaultToPendingBlock(options: CallOptions | EstimateFeeOptions): void {
if (options.blockNumber === undefined) {
// using || operator would not handle the zero case correctly
options.blockNumber = PENDING_BLOCK_NUMBER;
}
}

export interface DeployOptions {
salt?: string;
}
Expand Down Expand Up @@ -545,11 +556,7 @@ export class StarknetContract {
options: CallOptions = {}
): Promise<StringMap> {
options = copyWithBigint(options); // copy because of potential changes to the object

if (options.blockNumber === undefined) {
// using || operator would not handle the zero case correctly
options.blockNumber = PENDING_BLOCK_NUMBER;
}
defaultToPendingBlock(options);
const executed = await this.interact(InteractChoice.CALL, functionName, args, options);
return this.adaptOutput(functionName, executed.stdout.toString());
}
Expand All @@ -566,6 +573,7 @@ export class StarknetContract {
args?: StringMap,
options: EstimateFeeOptions = {}
): Promise<FeeEstimation> {
defaultToPendingBlock(options);
const executed = await this.interact(
InteractChoice.ESTIMATE_FEE,
functionName,
Expand Down

0 comments on commit af3834f

Please sign in to comment.