-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6cc1aa
commit 011452e
Showing
3 changed files
with
51 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/query/src/helpers/process-action-dutch-auction-schedule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { DutchAuctionDescription } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1alpha1/auction_pb'; | ||
import { IndexedDbInterface } from '@penumbra-zone/types/indexed-db'; | ||
import { getAuctionId, getAuctionNftMetadata } from '@penumbra-zone/wasm/auction'; | ||
|
||
export const processActionDutchAuctionSchedule = async ( | ||
description: DutchAuctionDescription, | ||
indexedDb: IndexedDbInterface, | ||
) => { | ||
const auctionId = getAuctionId(description); | ||
|
||
// Always a sequence number of 0 when starting a Dutch auction | ||
const seqNum = 0n; | ||
|
||
const metadata = getAuctionNftMetadata(auctionId, seqNum); | ||
|
||
await Promise.all([ | ||
indexedDb.saveAssetsMetadata(metadata), | ||
indexedDb.upsertAuction(auctionId, { | ||
auction: description, | ||
seqNum, | ||
}), | ||
]); | ||
}; |
19 changes: 19 additions & 0 deletions
19
packages/query/src/helpers/process-action-dutch-auction-withdraw.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { AuctionId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1alpha1/auction_pb'; | ||
import { IndexedDbInterface } from '@penumbra-zone/types/indexed-db'; | ||
import { getAuctionNftMetadata } from '@penumbra-zone/wasm/auction'; | ||
|
||
export const processActionDutchAuctionWithdraw = async ( | ||
auctionId: AuctionId, | ||
seqNum: bigint, | ||
indexedDb: IndexedDbInterface, | ||
) => { | ||
const metadata = getAuctionNftMetadata(auctionId, seqNum); | ||
|
||
await Promise.all([ | ||
indexedDb.saveAssetsMetadata(metadata), | ||
indexedDb.upsertAuction(auctionId, { | ||
seqNum, | ||
outstandingReserves: undefined, | ||
}), | ||
]); | ||
}; |