-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lit-task-auto-top-up): LIT-3897 - Implement pruning of expired c…
…apacity token NFTs
- Loading branch information
1 parent
eb3ef37
commit 94dc062
Showing
5 changed files
with
77 additions
and
36 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
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
36 changes: 36 additions & 0 deletions
36
packages/lit-task-auto-top-up/src/actions/pruneExpiredCapacityTokenNFT.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,36 @@ | ||
import { toErrorWithMessage } from '../errors'; | ||
import { PruneCapacityTokensFailure } from '../errors/PruneCapacityTokensFailure'; | ||
import { getConfig } from '../singletons/getConfig'; | ||
import { getLitContractsInstance } from '../singletons/getLitContracts'; | ||
import { RecipientDetail } from '../types/types'; | ||
|
||
export async function pruneExpiredCapacityTokenNFT({ | ||
recipientDetail, | ||
}: { | ||
recipientDetail: RecipientDetail; | ||
}) { | ||
const litContracts = await getLitContractsInstance(); | ||
const { logger } = getConfig(); | ||
|
||
const { recipientAddress } = recipientDetail; | ||
|
||
try { | ||
logger.log('Pruning expired capacity token NFTs for', recipientDetail); | ||
|
||
// @ts-ignore FIXME: This contract method has not yet been published | ||
await litContracts.rateLimitNftContract.write.pruneExpired(recipientAddress); | ||
} catch (e) { | ||
const err = toErrorWithMessage(e); | ||
|
||
throw new PruneCapacityTokensFailure( | ||
{ | ||
cause: err, | ||
info: { | ||
recipientAddress, | ||
}, | ||
name: 'PruneCapacityTokensFailure', | ||
}, | ||
'Failed to prune capacity tokens' | ||
); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/lit-task-auto-top-up/src/errors/PruneCapacityTokensFailure.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,3 @@ | ||
import VError from 'verror'; | ||
|
||
export class PruneCapacityTokensFailure extends VError {} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.