From 4070b154ca102c218824be831537cb896ed3c8fa Mon Sep 17 00:00:00 2001 From: Sebastien La Duca Date: Fri, 10 Nov 2023 11:13:26 -0500 Subject: [PATCH] (core) add gasEstimate field to PreSignOperation (#587) * add gasEstimate field to PreSignOperation * add gasEstimate field to PreSignOperation * changeset * rename field to `gasFeeEstimate` * fix unit test --- .changeset/sweet-trainers-wink.md | 5 +++++ packages/client/src/prepareOperation.ts | 3 +++ packages/client/test/utils.ts | 1 + packages/core/src/primitives/types.ts | 5 +++++ 4 files changed, 14 insertions(+) create mode 100644 .changeset/sweet-trainers-wink.md diff --git a/.changeset/sweet-trainers-wink.md b/.changeset/sweet-trainers-wink.md new file mode 100644 index 000000000..0f09cb3b6 --- /dev/null +++ b/.changeset/sweet-trainers-wink.md @@ -0,0 +1,5 @@ +--- +"@nocturne-xyz/core": patch +--- + +add `gasEstimate` to `PreSignOperation` diff --git a/packages/client/src/prepareOperation.ts b/packages/client/src/prepareOperation.ts index 7fb18840f..4f0b6f607 100644 --- a/packages/client/src/prepareOperation.ts +++ b/packages/client/src/prepareOperation.ts @@ -93,6 +93,9 @@ export async function prepareOperation( gasPrice: opRequest.gasPrice, deadline, atomicActions: true, // always default to atomic until we find reason not to + + // TODO: add actual estimate here + gasFeeEstimate: opRequest.gasAssetRefundThreshold, }; return op; diff --git a/packages/client/test/utils.ts b/packages/client/test/utils.ts index 8713b4144..9a42835d4 100644 --- a/packages/client/test/utils.ts +++ b/packages/client/test/utils.ts @@ -287,6 +287,7 @@ export function dummyOp( deadline: 0n, atomicActions: false, joinSplits, + gasFeeEstimate: 0n, }; } diff --git a/packages/core/src/primitives/types.ts b/packages/core/src/primitives/types.ts index 29ee0143b..f68d91aee 100644 --- a/packages/core/src/primitives/types.ts +++ b/packages/core/src/primitives/types.ts @@ -138,6 +138,11 @@ export interface BaseOperation { export interface PreSignOperation extends BaseOperation { joinSplits: PreSignJoinSplit[]; + + // gas fee estimate for the operation denominated in `encodedGasAsset` + // this is passed along to the snap so the user can see how much gas + // they will front for the operation + gasFeeEstimate: bigint; } export interface SignedOperation extends BaseOperation {