-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add carp funnel with stake delegation pool tracking * use local (tmp) carp client lib in the funnel just to test until the up to date version is published on npm * replace carp local client with 2.3.0 from npm * handle presync in carp funnel * use local (tmp) carp client lib in the funnel just to test until the up to date version is published on npm * add stopSlot setting to stop fetching * address review comments * Initial setups * Queries & rebase * Funnel fixes * Lint & minor fixes * More lint fixes * Remove checks for owner address * Address review comments * Minor fixes * number -> bigint for asset amount * bigint -> string * Update carp client and fix issue with big numbers in projected NFT * Fix lint * Asset -> policy id + asset name * Update carp client call * Fix paima tables * Remove tsoa routes * Address review comments --------- Co-authored-by: Enzo Cioppettini <[email protected]>
- Loading branch information
1 parent
7ca0a23
commit 13f2781
Showing
26 changed files
with
2,362 additions
and
1,095 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
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
69 changes: 69 additions & 0 deletions
69
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,69 @@ | ||
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 }, | ||
address: undefined, | ||
}), | ||
DEFAULT_FUNNEL_TIMEOUT | ||
); | ||
|
||
return events | ||
.map(e => eventToCdeDatum(e, extension, getBlockNumber(e.actionSlot))) | ||
.filter(e => e != null) | ||
.map(e => e!); | ||
} | ||
|
||
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, | ||
actionOutputIndex: event.actionOutputIndex != null ? event.actionOutputIndex : undefined, | ||
|
||
previousTxHash: event.previousTxHash != null ? event.previousTxHash : undefined, | ||
previousTxOutputIndex: | ||
event.previousTxOutputIndex != null ? event.previousTxOutputIndex : undefined, | ||
|
||
policyId: event.policyId, | ||
assetName: event.assetName, | ||
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.