-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Projected NFT funnel #259
Merged
Merged
Projected NFT funnel #259
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
09ece57
add carp funnel with stake delegation pool tracking
ecioppettini f30d983
use local (tmp) carp client lib in the funnel
ecioppettini a8f417c
replace carp local client with 2.3.0 from npm
ecioppettini 91ba6a5
handle presync in carp funnel
ecioppettini 3788338
use local (tmp) carp client lib in the funnel
ecioppettini 96d9449
add stopSlot setting to stop fetching
ecioppettini db32958
address review comments
ecioppettini acb7964
Initial setups
gostkin abd7a38
Queries & rebase
gostkin 8972ee0
Funnel fixes
gostkin 73d76e0
Lint & minor fixes
gostkin 0248309
More lint fixes
gostkin 1befbef
Remove checks for owner address
gostkin c00f752
Address review comments
gostkin 97e3cd5
Minor fixes
gostkin cf5a740
number -> bigint for asset amount
gostkin 13f4962
bigint -> string
gostkin c63fe7c
Update carp client and fix issue with big numbers in projected NFT
gostkin 627d81c
Fix lint
gostkin 965c624
Asset -> policy id + asset name
gostkin 38e41d8
Update carp client call
gostkin 7197527
Fix paima tables
gostkin f0b3492
Remove tsoa routes
gostkin d6dbcff
Address review comments
gostkin 1dc2c32
Merge pull request #274 from PaimaStudios/egostkin/projected-nft-spli…
gostkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ bin | |
|
||
# logs | ||
*.log | ||
|
||
.idea/ |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Empty file.
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
67 changes: 67 additions & 0 deletions
67
packages/engine/paima-funnel/src/cde/cardanoProjectedNFT.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,67 @@ | ||
import type { | ||
CdeCardanoProjectedNFTDatum, | ||
ChainDataExtensionCardanoProjectedNFT, | ||
ChainDataExtensionDatum, | ||
} from '@paima/sm'; | ||
import { ChainDataExtensionDatumType, DEFAULT_FUNNEL_TIMEOUT, timeout } from '@paima/utils'; | ||
import { Routes, query } from '@dcspark/carp-client/client/src'; | ||
import type { ProjectedNftRangeResponse } from '@dcspark/carp-client/shared/models/ProjectedNftRange'; | ||
|
||
export default async function getCdeProjectedNFTData( | ||
url: string, | ||
extension: ChainDataExtensionCardanoProjectedNFT, | ||
fromAbsoluteSlot: number, | ||
toAbsoluteSlot: number, | ||
getBlockNumber: (slot: number) => number | ||
): Promise<ChainDataExtensionDatum[]> { | ||
const events = await timeout( | ||
query(url, Routes.projectedNftEventsRange, { | ||
range: { minSlot: fromAbsoluteSlot, maxSlot: toAbsoluteSlot }, | ||
}), | ||
DEFAULT_FUNNEL_TIMEOUT | ||
); | ||
|
||
return events | ||
.map(e => eventToCdeDatum(e, extension, getBlockNumber(e.actionSlot))) | ||
.filter(e => e != null) | ||
.map(e => e!); | ||
ecioppettini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
function eventToCdeDatum( | ||
event: ProjectedNftRangeResponse[0], | ||
extension: ChainDataExtensionCardanoProjectedNFT, | ||
blockNumber: number | ||
): CdeCardanoProjectedNFTDatum | null { | ||
if ( | ||
event.actionTxId === null || | ||
event.actionTxId == '' || | ||
event.status === null || | ||
event.status == '' | ||
) { | ||
return null; | ||
} | ||
|
||
return { | ||
cdeId: extension.cdeId, | ||
cdeDatumType: ChainDataExtensionDatumType.CardanoProjectedNFT, | ||
blockNumber, | ||
payload: { | ||
ownerAddress: event.ownerAddress != null ? event.ownerAddress : '', | ||
|
||
actionTxId: event.actionTxId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that games only care about NFTs getting locked and queued to unlock. We don't care if the user ever actually ends up withdrawing their NFT from the lock later. |
||
actionOutputIndex: event.actionOutputIndex != null ? event.actionOutputIndex : undefined, | ||
|
||
previousTxHash: event.previousTxHash != null ? event.previousTxHash : undefined, | ||
previousTxOutputIndex: | ||
event.previousTxOutputIndex != null ? event.previousTxOutputIndex : undefined, | ||
|
||
asset: event.asset, | ||
amount: event.amount, | ||
status: event.status, | ||
plutusDatum: event.plutusDatum != null ? event.plutusDatum : '', | ||
|
||
forHowLong: event.forHowLong != null ? event.forHowLong : undefined, | ||
}, | ||
scheduledPrefix: extension.scheduledPrefix, | ||
}; | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this handle pagination properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, as long as the range is not too big it will work fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the request is not split to pages