Skip to content

Commit

Permalink
(core) add gasEstimate field to PreSignOperation (#587)
Browse files Browse the repository at this point in the history
* add gasEstimate field to PreSignOperation

* add gasEstimate field to PreSignOperation

* changeset

* rename field to `gasFeeEstimate`

* fix unit test
  • Loading branch information
Sladuca authored Nov 10, 2023
1 parent 94bb921 commit 4070b15
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-trainers-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nocturne-xyz/core": patch
---

add `gasEstimate` to `PreSignOperation`
3 changes: 3 additions & 0 deletions packages/client/src/prepareOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/client/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export function dummyOp(
deadline: 0n,
atomicActions: false,
joinSplits,
gasFeeEstimate: 0n,
};
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/primitives/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4070b15

Please sign in to comment.